From eab56fb5d5d6d5585a7ad7d665adc7c5fb5ec249 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 9 Feb 2012 10:39:16 +0000 Subject: [PATCH] -fixing #2139 --- src/fs/fs_dirmetascan.c | 3 ++- src/fs/gnunet-publish.c | 30 ++++++++++++++++++++++++------ src/include/gnunet_fs_service.h | 3 ++- src/util/helper.c | 2 +- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/fs/fs_dirmetascan.c b/src/fs/fs_dirmetascan.c index 5b7d2d0c1..1653eebd4 100644 --- a/src/fs/fs_dirmetascan.c +++ b/src/fs/fs_dirmetascan.c @@ -92,7 +92,8 @@ struct GNUNET_FS_DirScanner /** - * Abort the scan. + * Abort the scan. Must not be called from within the progress_callback + * function. * * @param ds directory scanner structure */ diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c index 406433a71..370f1062c 100644 --- a/src/fs/gnunet-publish.c +++ b/src/fs/gnunet-publish.c @@ -95,6 +95,29 @@ do_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } +/** + * Stop the directory scanner (we had an error). + * + * @param cls closure + * @param tc scheduler context + */ +static void +stop_scanner_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + kill_task = GNUNET_SCHEDULER_NO_TASK; + GNUNET_FS_directory_scan_abort (ds); + ds = NULL; + if (namespace != NULL) + { + GNUNET_FS_namespace_delete (namespace, GNUNET_NO); + namespace = NULL; + } + GNUNET_FS_stop (ctx); + ctx = NULL; + ret = 1; +} + + /** * Called by FS client to give information about the progress of an * operation. @@ -487,17 +510,12 @@ directory_scan_cb (void *cls, break; case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR: FPRINTF (stdout, "%s", _("Internal error scanning directory.\n")); - GNUNET_FS_directory_scan_abort (ds); - ds = NULL; - if (namespace != NULL) - GNUNET_FS_namespace_delete (namespace, GNUNET_NO); - GNUNET_FS_stop (ctx); if (kill_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (kill_task); kill_task = GNUNET_SCHEDULER_NO_TASK; } - ret = 1; + kill_task = GNUNET_SCHEDULER_add_now (&stop_scanner_task, NULL); break; default: GNUNET_assert (0); diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 454a5c953..9707a8eb7 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h @@ -2725,7 +2725,8 @@ GNUNET_FS_directory_scan_start (const char *filename, /** - * Abort the scan. + * Abort the scan. Must not be called from within the progress_callback + * function. * * @param ds directory scanner structure */ diff --git a/src/util/helper.c b/src/util/helper.c index d9458aedb..e5d336e2f 100644 --- a/src/util/helper.c +++ b/src/util/helper.c @@ -194,7 +194,7 @@ stop_helper (struct GNUNET_HELPER_Handle *h) GNUNET_free (qe); } /* purge MST buffer */ - GNUNET_SERVER_mst_receive (h->mst, NULL, NULL, 0, GNUNET_YES, GNUNET_NO); + (void) GNUNET_SERVER_mst_receive (h->mst, NULL, NULL, 0, GNUNET_YES, GNUNET_NO); } -- 2.25.1