gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r18960 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r18960 - gnunet/src/util
Date: Tue, 3 Jan 2012 22:29:22 +0100

Author: grothoff
Date: 2012-01-03 22:29:22 +0100 (Tue, 03 Jan 2012)
New Revision: 18960

Modified:
   gnunet/src/util/helper.c
Log:
-fix

Modified: gnunet/src/util/helper.c
===================================================================
--- gnunet/src/util/helper.c    2012-01-03 21:02:45 UTC (rev 18959)
+++ gnunet/src/util/helper.c    2012-01-03 21:29:22 UTC (rev 18960)
@@ -218,7 +218,7 @@
 helper_read (void *cls,
             const struct GNUNET_SCHEDULER_TaskContext *tsdkctx)
 {
-  struct GNUNET_HELPER_Handle*h = cls;
+  struct GNUNET_HELPER_Handle *h = cls;
   char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE];
   ssize_t t;
 
@@ -231,7 +231,7 @@
     return;
   }
   t = GNUNET_DISK_file_read (h->fh_from_helper, &buf, sizeof (buf));
-  if (t <= 0)
+  if (t < 0)
   {
     /* On read-error, restart the helper */
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -245,6 +245,20 @@
                                    &restart_task, h);
     return;
   }
+  if (0 == t)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 
+               _("Got 0 bytes from helper `%s' (EOF)\n"),
+               h->binary_name);
+#if 0
+    stop_helper (h);
+    /* Restart the helper */
+    h->restart_task =
+      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                   &restart_task, h);
+#endif
+    return;
+  }
   if (GNUNET_SYSERR ==
       GNUNET_SERVER_mst_receive (h->mst, NULL, buf, t, GNUNET_NO, GNUNET_NO))
   {
@@ -285,10 +299,8 @@
   }
   h->fh_from_helper =
       GNUNET_DISK_pipe_handle (h->helper_out, GNUNET_DISK_PIPE_END_READ);
-  GNUNET_DISK_pipe_close_end (h->helper_out, GNUNET_DISK_PIPE_END_WRITE);
   h->fh_to_helper =
       GNUNET_DISK_pipe_handle (h->helper_in, GNUNET_DISK_PIPE_END_WRITE);
-  GNUNET_DISK_pipe_close_end (h->helper_in, GNUNET_DISK_PIPE_END_READ);
   h->helper_proc =
       GNUNET_OS_start_process_vap (h->helper_in, h->helper_out,
                                   h->binary_name,
@@ -302,6 +314,8 @@
                                    &restart_task, h);    
     return;
   }
+  GNUNET_DISK_pipe_close_end (h->helper_out, GNUNET_DISK_PIPE_END_WRITE);
+  GNUNET_DISK_pipe_close_end (h->helper_in, GNUNET_DISK_PIPE_END_READ);
   h->read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
                                                 h->fh_from_helper, 
                                                 &helper_read, 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]