-round expiration times to full seconds
[oweals/gnunet.git] / src / fs / fs_dirmetascan.c
index 6dac690ff525370e36a3222c2a5f19dc08d5294c..7139ea45a99563ef6dfa57cfd23bd4d05ddcd3cb 100644 (file)
@@ -102,7 +102,7 @@ GNUNET_FS_directory_scan_abort (struct GNUNET_FS_DirScanner *ds)
 {
   /* terminate helper */
   if (NULL != ds->helper)
-    GNUNET_HELPER_stop (ds->helper);
+    GNUNET_HELPER_stop (ds->helper, GNUNET_NO);
   
   /* free resources */
   if (NULL != ds->toplevel)
@@ -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, GNUNET_NO);
+    ds->helper = NULL;
+  }
   ds->progress_callback (ds->progress_callback_cls, 
                         NULL, GNUNET_SYSERR,
                         GNUNET_FS_DIRSCANNER_FINISHED);    
@@ -414,6 +417,25 @@ 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;
+  if (GNUNET_SCHEDULER_NO_TASK != ds->stop_task)
+    return; /* normal death, was finished */
+  ds->progress_callback (ds->progress_callback_cls, 
+                        NULL, GNUNET_SYSERR,
+                        GNUNET_FS_DIRSCANNER_INTERNAL_ERROR);  
+}
+
+
 /**
  * Start a directory scanner thread.
  *
@@ -454,12 +476,13 @@ GNUNET_FS_directory_scan_start (const char *filename,
   ds->args[1] = ds->filename_expanded;
   ds->args[2] = ds->ex_arg;
   ds->args[3] = NULL;
-  ds->helper = GNUNET_HELPER_start ("gnunet-helper-fs-publish",
+  ds->helper = GNUNET_HELPER_start (GNUNET_NO,
+                                   "gnunet-helper-fs-publish",
                                    ds->args,
                                    &process_helper_msgs,
-                                   ds);
+                                   &helper_died_cb, ds);
   if (NULL == ds->helper)
-  {
+    {
     GNUNET_free (filename_expanded);
     GNUNET_free (ds);
     return NULL;