diff options
-rw-r--r-- | src/fs/fs_api.h | 6 | ||||
-rw-r--r-- | src/fs/fs_publish.c | 50 | ||||
-rw-r--r-- | src/fs/gnunet-publish.c | 20 | ||||
-rw-r--r-- | src/util/client.c | 5 | ||||
-rw-r--r-- | src/util/os_priority.c | 1 |
5 files changed, 63 insertions, 19 deletions
diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h index 5ff0c4f1d..9ecffb88d 100644 --- a/src/fs/fs_api.h +++ b/src/fs/fs_api.h @@ -1325,6 +1325,12 @@ struct GNUNET_FS_PublishContext int rid; /** + * Set to #GNUNET_YES if we were able to publish any block. + * (and thus unindexing on error might make sense). + */ + int any_done; + + /** * Set to #GNUNET_YES if all processing has completed. */ int all_done; diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c index 211f800e6..d9c732ee8 100644 --- a/src/fs/fs_publish.c +++ b/src/fs/fs_publish.c @@ -112,7 +112,8 @@ publish_cleanup (struct GNUNET_FS_PublishContext *pc) * @param msg error message (or NULL) */ static void -ds_put_cont (void *cls, int success, +ds_put_cont (void *cls, + int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) { @@ -130,14 +131,19 @@ ds_put_cont (void *cls, int success, pi.value.publish.specifics.error.message = pc->fi_pos->emsg; pc->fi_pos->client_info = GNUNET_FS_publish_make_status_ (&pi, pc, pc->fi_pos, 0); - if ((pc->fi_pos->is_directory != GNUNET_YES) && - (pc->fi_pos->filename != NULL) && - (pc->fi_pos->data.file.do_index == GNUNET_YES)) + if ((GNUNET_YES != pc->fi_pos->is_directory) && + (NULL != pc->fi_pos->filename) && + (GNUNET_YES == pc->any_done) && + (GNUNET_YES == pc->fi_pos->data.file.do_index)) { /* run unindex to clean up */ - GNUNET_FS_unindex_start (pc->h, pc->fi_pos->filename, NULL); + GNUNET_FS_unindex_start (pc->h, + pc->fi_pos->filename, + NULL); } + return; } + pc->any_done = GNUNET_YES; GNUNET_assert (NULL == pc->upload_task); pc->upload_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_BACKGROUND, @@ -506,26 +512,40 @@ block_proc (void *cls, odb.file_id = p->data.file.file_id; GNUNET_assert (pc->qre == NULL); pc->qre = - GNUNET_DATASTORE_put (pc->dsh, (p->is_directory == GNUNET_YES) ? 0 : pc->rid, - &chk->query, sizeof (struct OnDemandBlock), &odb, + GNUNET_DATASTORE_put (pc->dsh, + (p->is_directory == GNUNET_YES) ? 0 : pc->rid, + &chk->query, + sizeof (struct OnDemandBlock), + &odb, GNUNET_BLOCK_TYPE_FS_ONDEMAND, - p->bo.content_priority, p->bo.anonymity_level, - p->bo.replication_level, p->bo.expiration_time, - -2, 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, + p->bo.content_priority, + p->bo.anonymity_level, + p->bo.replication_level, + p->bo.expiration_time, + -2, 1, + GNUNET_CONSTANTS_SERVICE_TIMEOUT, &ds_put_cont, pc); return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing block `%s' for offset %llu with size %u\n", - GNUNET_h2s (&chk->query), (unsigned long long) offset, + GNUNET_h2s (&chk->query), + (unsigned long long) offset, (unsigned int) block_size); GNUNET_assert (pc->qre == NULL); pc->qre = GNUNET_DATASTORE_put (pc->dsh, (p->is_directory == GNUNET_YES) ? 0 : pc->rid, - &chk->query, block_size, block, type, - p->bo.content_priority, p->bo.anonymity_level, - p->bo.replication_level, p->bo.expiration_time, -2, - 1, GNUNET_CONSTANTS_SERVICE_TIMEOUT, &ds_put_cont, + &chk->query, + block_size, + block, + type, + p->bo.content_priority, + p->bo.anonymity_level, + p->bo.replication_level, + p->bo.expiration_time, + -2, 1, + GNUNET_CONSTANTS_SERVICE_TIMEOUT, + &ds_put_cont, pc); } diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index 975f5d2ad..b213218e4 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c @@ -293,15 +293,29 @@ progress_cb (void *cls, case GNUNET_FS_STATUS_PUBLISH_STOPPED: GNUNET_break (NULL == pc); return NULL; + case GNUNET_FS_STATUS_UNINDEX_START: + FPRINTF (stderr, + "%s", + _("Starting cleanup after abort\n")); + return NULL; case GNUNET_FS_STATUS_UNINDEX_PROGRESS: return NULL; case GNUNET_FS_STATUS_UNINDEX_COMPLETED: FPRINTF (stderr, "%s", - _("Cleanup after abort complete.\n")); + _("Cleanup after abort completed.\n")); + GNUNET_FS_unindex_stop (info->value.unindex.uc); + return NULL; + case GNUNET_FS_STATUS_UNINDEX_ERROR: + FPRINTF (stderr, + "%s", + _("Cleanup after abort failed.\n")); + GNUNET_FS_unindex_stop (info->value.unindex.uc); return NULL; default: - FPRINTF (stderr, _("Unexpected status: %d\n"), info->status); + FPRINTF (stderr, + _("Unexpected status: %d\n"), + info->status); return NULL; } return ""; /* non-null */ @@ -316,7 +330,7 @@ progress_cb (void *cls, * @param plugin_name name of the plugin that generated the meta data * @param type type of the meta data * @param format format of data - * @param data_mime_type mime type of data + * @param data_mime_type mime type of @a data * @param data value of the meta data * @param data_size number of bytes in @a data * @return always 0 diff --git a/src/util/client.c b/src/util/client.c index 46bb6a86b..ad48c31a8 100644 --- a/src/util/client.c +++ b/src/util/client.c @@ -70,7 +70,7 @@ struct GNUNET_CLIENT_TransmitHandle * If we are re-trying and are delaying to do so, * handle to the scheduled task managing the delay. */ - struct GNUNET_SCHEDULER_Task * reconnect_task; + struct GNUNET_SCHEDULER_Task *reconnect_task; /** * Timeout for the operation overall. @@ -1108,6 +1108,7 @@ client_delayed_retry (void *cls, "Transmission failed %u times, trying again in %s.\n", MAX_ATTEMPTS - th->attempts_left, GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); + GNUNET_assert (NULL == th->th); GNUNET_assert (NULL == th->reconnect_task); th->reconnect_task = GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th); @@ -1191,6 +1192,7 @@ client_notify (void *cls, GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); client->th = th; GNUNET_assert (NULL == th->reconnect_task); + GNUNET_assert (NULL == th->th); th->reconnect_task = GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th); return 0; @@ -1259,6 +1261,7 @@ GNUNET_CLIENT_notify_transmit_ready (struct GNUNET_CLIENT_Connection *client, client->th = th; if (NULL == client->connection) { + GNUNET_assert (NULL == th->th); GNUNET_assert (NULL == th->reconnect_task); th->reconnect_task = GNUNET_SCHEDULER_add_delayed (client->back_off, diff --git a/src/util/os_priority.c b/src/util/os_priority.c index 480ca09bb..065009ae5 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c @@ -492,6 +492,7 @@ open_dev_null (int target_fd, * (when they are non-NULL). * @param pipe_stdin pipe to use to send input to child process (or NULL) * @param pipe_stdout pipe to use to get output from child process (or NULL) + * @param pipe_stderr pipe to use for stderr for child process (or NULL) * @param lsocks array of listen sockets to dup systemd-style (or NULL); * must be NULL on platforms where dup is not supported * @param filename name of the binary |