-GArik: fix typo
[oweals/gnunet.git] / src / util / helper.c
index 6ebc3a444996dcfaf16e7d1888fc06ca947f6f68..e5d336e2fb88cbdc1e28bb962c4b7138b28c4649 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);
 }
 
 
@@ -216,14 +217,14 @@ restart_task (void *cls,
  */
 static void
 helper_read (void *cls,
-            const struct GNUNET_SCHEDULER_TaskContext *tsdkctx)
+            const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_HELPER_Handle *h = cls;
   char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE];
   ssize_t t;
 
   h->read_task = GNUNET_SCHEDULER_NO_TASK;
-  if (0 != (tsdkctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
   {
     /* try again */
     h->read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
@@ -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);
 }
 
 
@@ -387,7 +387,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);
@@ -404,7 +405,7 @@ GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h)
  */
 static void
 helper_write (void *cls,
-            const struct GNUNET_SCHEDULER_TaskContext *tsdkctx)
+            const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_HELPER_Handle *h = cls;
   struct HelperMessageQueueEntry *qe;
@@ -412,7 +413,7 @@ helper_write (void *cls,
   ssize_t t;
 
   h->write_task = GNUNET_SCHEDULER_NO_TASK;
-  if (0 != (tsdkctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
   {
     /* try again */
     h->write_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,