-fixing #2139
authorChristian Grothoff <christian@grothoff.org>
Thu, 9 Feb 2012 10:39:16 +0000 (10:39 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 9 Feb 2012 10:39:16 +0000 (10:39 +0000)
src/fs/fs_dirmetascan.c
src/fs/gnunet-publish.c
src/include/gnunet_fs_service.h
src/util/helper.c

index 5b7d2d0c1a811fb90cada8a17d4003748a9dc94d..1653eebd4214d8ad2278b9a06384b67024fea574 100644 (file)
@@ -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
  */
index 406433a71295b56b12e12af7d6e347710aa0c6e8..370f1062c1cab93682e2b9d447c98da456bd2a9c 100644 (file)
@@ -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);
index 454a5c95300dd50bb9495c4dc9e08040b68d2aca..9707a8eb7b97176d617afabc87c392f93bfec24f 100644 (file)
@@ -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
  */
index d9458aedbe078a827f57a221053479af84775d69..e5d336e2fb88cbdc1e28bb962c4b7138b28c4649 100644 (file)
@@ -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);
 }