-doxygen
[oweals/gnunet.git] / src / util / helper.c
index c7e05923760be1897d0c13f1afa3904f9fb644fb..43ec23a88278e00cc65928eba3e7b69eb80a2e3a 100644 (file)
@@ -189,11 +189,12 @@ stop_helper (struct GNUNET_HELPER_Handle *h)
     GNUNET_CONTAINER_DLL_remove (h->mq_head,
                                 h->mq_tail,
                                 qe);
-    qe->cont (qe->cont_cls, GNUNET_NO);
+    if (NULL != qe->cont)
+      qe->cont (qe->cont_cls, GNUNET_NO);
     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);
 }
 
 
@@ -263,6 +264,8 @@ helper_read (void *cls,
              _("Got %u bytes from helper `%s'\n"),
              (unsigned int) t,
              h->binary_name);
+  h->read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
+                                                h->fh_from_helper, &helper_read, h);
   if (GNUNET_SYSERR ==
       GNUNET_SERVER_mst_receive (h->mst, NULL, buf, t, GNUNET_NO, GNUNET_NO))
   {
@@ -275,10 +278,7 @@ helper_read (void *cls,
         GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
                                       &restart_task, h);
     return;
-
   }
-  h->read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                                h->fh_from_helper, &helper_read, h);
 }
 
 
@@ -306,7 +306,8 @@ start_helper (struct GNUNET_HELPER_Handle *h)
   h->fh_to_helper =
       GNUNET_DISK_pipe_handle (h->helper_in, GNUNET_DISK_PIPE_END_WRITE);
   h->helper_proc =
-      GNUNET_OS_start_process_vap (h->helper_in, h->helper_out,
+      GNUNET_OS_start_process_vap (GNUNET_NO,
+                                  h->helper_in, h->helper_out,
                                   h->binary_name,
                                   h->binary_argv);
   if (NULL == h->helper_proc)
@@ -387,7 +388,8 @@ GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h)
     GNUNET_CONTAINER_DLL_remove (h->mq_head,
                                 h->mq_tail,
                                 qe);
-    qe->cont (qe->cont_cls, GNUNET_SYSERR);
+    if (NULL != qe->cont)
+      qe->cont (qe->cont_cls, GNUNET_SYSERR);
     GNUNET_free (qe);
   }
   stop_helper (h);