-options to play with
[oweals/gnunet.git] / src / fs / fs_dirmetascan.c
index fb20a2b376be83e1c72d4dc719c14e42d7f8ccc4..8755acf714cf0b1c75b8b41b0662a67ca9785a53 100644 (file)
@@ -232,8 +232,11 @@ finish_scan (void *cls,
   struct GNUNET_FS_DirScanner *ds = cls;
 
   ds->stop_task = GNUNET_SCHEDULER_NO_TASK;
-  GNUNET_HELPER_stop (ds->helper);
-  ds->helper = NULL;
+  if (NULL != ds->helper)
+  {
+    GNUNET_HELPER_stop (ds->helper);
+    ds->helper = NULL;
+  }
   ds->progress_callback (ds->progress_callback_cls, 
                         NULL, GNUNET_SYSERR,
                         GNUNET_FS_DIRSCANNER_FINISHED);    
@@ -414,6 +417,23 @@ process_helper_msgs (void *cls,
 }
 
 
+/**
+ * Function called if our helper process died.
+ *
+ * @param cls the 'struct GNUNET_FS_DirScanner' callback.
+ */
+static void
+helper_died_cb (void *cls)
+{
+  struct GNUNET_FS_DirScanner *ds = cls;
+
+  ds->helper = NULL;
+  ds->progress_callback (ds->progress_callback_cls, 
+                        NULL, GNUNET_SYSERR,
+                        GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);  
+}
+
+
 /**
  * Start a directory scanner thread.
  *
@@ -458,9 +478,9 @@ GNUNET_FS_directory_scan_start (const char *filename,
                                    "gnunet-helper-fs-publish",
                                    ds->args,
                                    &process_helper_msgs,
-                                   NULL, ds);
+                                   &helper_died_cb, ds);
   if (NULL == ds->helper)
-  {
+    {
     GNUNET_free (filename_expanded);
     GNUNET_free (ds);
     return NULL;