diff options
-rw-r--r-- | src/fs/fs_api.c | 25 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 13 |
2 files changed, 25 insertions, 13 deletions
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index f16ced603..040ee1b7f 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c | |||
@@ -307,7 +307,11 @@ process_job_queue (void *cls, | |||
307 | num_downloads_change, | 307 | num_downloads_change, |
308 | GNUNET_STRINGS_relative_time_to_string (restart_at, GNUNET_YES)); | 308 | GNUNET_STRINGS_relative_time_to_string (restart_at, GNUNET_YES)); |
309 | 309 | ||
310 | /* make sure we run again */ | 310 | /* make sure we run again, callbacks might have |
311 | already re-scheduled the job, so cancel such | ||
312 | an operation (if it exists) */ | ||
313 | if (NULL != h->queue_job) | ||
314 | GNUNET_SCHEDULER_cancel (h->queue_job); | ||
311 | h->queue_job = | 315 | h->queue_job = |
312 | GNUNET_SCHEDULER_add_delayed (restart_at, &process_job_queue, h); | 316 | GNUNET_SCHEDULER_add_delayed (restart_at, &process_job_queue, h); |
313 | } | 317 | } |
@@ -343,7 +347,7 @@ GNUNET_FS_queue_ (struct GNUNET_FS_Handle *h, | |||
343 | qe->priority = priority; | 347 | qe->priority = priority; |
344 | GNUNET_CONTAINER_DLL_insert_after (h->pending_head, h->pending_tail, | 348 | GNUNET_CONTAINER_DLL_insert_after (h->pending_head, h->pending_tail, |
345 | h->pending_tail, qe); | 349 | h->pending_tail, qe); |
346 | if (h->queue_job != NULL) | 350 | if (NULL != h->queue_job) |
347 | GNUNET_SCHEDULER_cancel (h->queue_job); | 351 | GNUNET_SCHEDULER_cancel (h->queue_job); |
348 | h->queue_job = GNUNET_SCHEDULER_add_now (&process_job_queue, h); | 352 | h->queue_job = GNUNET_SCHEDULER_add_now (&process_job_queue, h); |
349 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 353 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -371,7 +375,7 @@ GNUNET_FS_dequeue_ (struct GNUNET_FS_QueueEntry *qe) | |||
371 | stop_job (qe); | 375 | stop_job (qe); |
372 | GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, qe); | 376 | GNUNET_CONTAINER_DLL_remove (h->pending_head, h->pending_tail, qe); |
373 | GNUNET_free (qe); | 377 | GNUNET_free (qe); |
374 | if (h->queue_job != NULL) | 378 | if (NULL != h->queue_job) |
375 | GNUNET_SCHEDULER_cancel (h->queue_job); | 379 | GNUNET_SCHEDULER_cancel (h->queue_job); |
376 | h->queue_job = GNUNET_SCHEDULER_add_now (&process_job_queue, h); | 380 | h->queue_job = GNUNET_SCHEDULER_add_now (&process_job_queue, h); |
377 | } | 381 | } |
@@ -3039,11 +3043,12 @@ deserialize_download_file (void *cls, const char *filename) | |||
3039 | * Deserialize informatin about pending operations. | 3043 | * Deserialize informatin about pending operations. |
3040 | * | 3044 | * |
3041 | * @param master_path which master directory should be scanned | 3045 | * @param master_path which master directory should be scanned |
3042 | * @param proc function to call for each entry (will get 'h' for 'cls') | 3046 | * @param proc function to call for each entry (will get @a h for 'cls') |
3043 | * @param h the 'struct GNUNET_FS_Handle*' | 3047 | * @param h the `struct GNUNET_FS_Handle *` |
3044 | */ | 3048 | */ |
3045 | static void | 3049 | static void |
3046 | deserialization_master (const char *master_path, GNUNET_FileNameCallback proc, | 3050 | deserialization_master (const char *master_path, |
3051 | GNUNET_FileNameCallback proc, | ||
3047 | struct GNUNET_FS_Handle *h) | 3052 | struct GNUNET_FS_Handle *h) |
3048 | { | 3053 | { |
3049 | char *dn; | 3054 | char *dn; |
@@ -3127,17 +3132,19 @@ GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
3127 | 3132 | ||
3128 | /** | 3133 | /** |
3129 | * Close our connection with the file-sharing service. | 3134 | * Close our connection with the file-sharing service. |
3130 | * The callback given to GNUNET_FS_start will no longer be | 3135 | * The callback given to #GNUNET_FS_start() will no longer be |
3131 | * called after this function returns. | 3136 | * called after this function returns. |
3137 | * This function MUST NOT be called from within the | ||
3138 | * callback itself. | ||
3132 | * | 3139 | * |
3133 | * @param h handle that was returned from #GNUNET_FS_start() | 3140 | * @param h handle that was returned from #GNUNET_FS_start() |
3134 | */ | 3141 | */ |
3135 | void | 3142 | void |
3136 | GNUNET_FS_stop (struct GNUNET_FS_Handle *h) | 3143 | GNUNET_FS_stop (struct GNUNET_FS_Handle *h) |
3137 | { | 3144 | { |
3138 | while (h->top_head != NULL) | 3145 | while (NULL != h->top_head) |
3139 | h->top_head->ssf (h->top_head->ssf_cls); | 3146 | h->top_head->ssf (h->top_head->ssf_cls); |
3140 | if (h->queue_job != NULL) | 3147 | if (NULL != h->queue_job) |
3141 | GNUNET_SCHEDULER_cancel (h->queue_job); | 3148 | GNUNET_SCHEDULER_cancel (h->queue_job); |
3142 | GNUNET_free (h->client_name); | 3149 | GNUNET_free (h->client_name); |
3143 | GNUNET_free (h); | 3150 | GNUNET_free (h); |
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 64666dc52..f9c56db64 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -1703,16 +1703,21 @@ struct GNUNET_FS_Handle; | |||
1703 | */ | 1703 | */ |
1704 | struct GNUNET_FS_Handle * | 1704 | struct GNUNET_FS_Handle * |
1705 | GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 1705 | GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
1706 | const char *client_name, GNUNET_FS_ProgressCallback upcb, | 1706 | const char *client_name, |
1707 | void *upcb_cls, enum GNUNET_FS_Flags flags, ...); | 1707 | GNUNET_FS_ProgressCallback upcb, |
1708 | void *upcb_cls, | ||
1709 | enum GNUNET_FS_Flags flags, | ||
1710 | ...); | ||
1708 | 1711 | ||
1709 | 1712 | ||
1710 | /** | 1713 | /** |
1711 | * Close our connection with the file-sharing service. | 1714 | * Close our connection with the file-sharing service. |
1712 | * The callback given to GNUNET_FS_start will no longer be | 1715 | * The callback given to #GNUNET_FS_start() will no longer be |
1713 | * called after this function returns. | 1716 | * called after this function returns. |
1717 | * This function MUST NOT be called from within the | ||
1718 | * callback itself. | ||
1714 | * | 1719 | * |
1715 | * @param h handle that was returned from GNUNET_FS_start | 1720 | * @param h handle that was returned from #GNUNET_FS_start() |
1716 | */ | 1721 | */ |
1717 | void | 1722 | void |
1718 | GNUNET_FS_stop (struct GNUNET_FS_Handle *h); | 1723 | GNUNET_FS_stop (struct GNUNET_FS_Handle *h); |