indentation
[oweals/gnunet.git] / src / vpn / gnunet-helper-vpn-api.c
index 195a79217e1f47e0d2d31ec6ec4d217fd413160d..16bfcbd2ec382afca9672771c306946636314990 100644 (file)
@@ -45,9 +45,11 @@ stop_helper (struct GNUNET_VPN_HELPER_Handle *handle)
   GNUNET_DISK_pipe_close (handle->helper_in);
   GNUNET_DISK_pipe_close (handle->helper_out);
 
-  GNUNET_SERVER_mst_destroy(handle->mst);
+  GNUNET_SERVER_mst_destroy (handle->mst);
 }
 
+extern GNUNET_SCHEDULER_TaskIdentifier shs_task;
+
 /**
  * Read from the helper-process
  */
@@ -55,6 +57,7 @@ static void
 helper_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tsdkctx)
 {
   struct GNUNET_VPN_HELPER_Handle *handle = cls;
+
   /* no message can be bigger then 64k */
   char buf[65535];
 
@@ -65,34 +68,32 @@ helper_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tsdkctx)
 
   /* On read-error, restart the helper */
   if (t <= 0)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "Read error for header from vpn-helper: %m\n");
-      stop_helper (handle);
-
-      /* Restart the helper */
-      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
-                                    handle->restart_task, handle);
-      return;
-    }
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Read error for header from vpn-helper: %m\n");
+    stop_helper (handle);
+
+    /* Restart the helper */
+    shs_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                             handle->restart_task, handle);
+    return;
+  }
 
   if (GNUNET_SYSERR ==
       GNUNET_SERVER_mst_receive (handle->mst, handle->client, buf, t, 0, 0))
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "SYSERR from mst\n");
-      stop_helper (handle);
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "SYSERR from mst\n");
+    stop_helper (handle);
 
-      /* Restart the helper */
-      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
-                                    handle->restart_task, handle);
-      return;
+    /* Restart the helper */
+    shs_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                             handle->restart_task, handle);
+    return;
 
-    }
+  }
 
   GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                  handle->fh_from_helper, &helper_read,
-                                  handle);
+                                  handle->fh_from_helper, &helper_read, handle);
 }
 
 void
@@ -112,7 +113,7 @@ start_helper (const char *ifname,
               GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls)
 {
   struct GNUNET_VPN_HELPER_Handle *handle =
-    GNUNET_malloc (sizeof (struct GNUNET_VPN_HELPER_Handle));
+      GNUNET_malloc (sizeof (struct GNUNET_VPN_HELPER_Handle));
 
   handle->helper_in = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO);
   handle->helper_out = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES);
@@ -120,20 +121,20 @@ start_helper (const char *ifname,
   handle->restart_task = restart_task;
 
   if (handle->helper_in == NULL || handle->helper_out == NULL)
-    {
-      GNUNET_free (handle);
-      return NULL;
-    }
+  {
+    GNUNET_free (handle);
+    return NULL;
+  }
 
   handle->helper_proc =
-    GNUNET_OS_start_process (handle->helper_in, handle->helper_out,
-                             "gnunet-helper-vpn", process_name, ifname,
-                             ipv6addr, ipv6prefix, ipv4addr, ipv4mask, NULL);
+      GNUNET_OS_start_process (handle->helper_in, handle->helper_out,
+                               "gnunet-helper-vpn", process_name, ifname,
+                               ipv6addr, ipv6prefix, ipv4addr, ipv4mask, NULL);
 
   handle->fh_from_helper =
-    GNUNET_DISK_pipe_handle (handle->helper_out, GNUNET_DISK_PIPE_END_READ);
+      GNUNET_DISK_pipe_handle (handle->helper_out, GNUNET_DISK_PIPE_END_READ);
   handle->fh_to_helper =
-    GNUNET_DISK_pipe_handle (handle->helper_in, GNUNET_DISK_PIPE_END_WRITE);
+      GNUNET_DISK_pipe_handle (handle->helper_in, GNUNET_DISK_PIPE_END_WRITE);
 
   GNUNET_DISK_pipe_close_end (handle->helper_out, GNUNET_DISK_PIPE_END_WRITE);
   GNUNET_DISK_pipe_close_end (handle->helper_in, GNUNET_DISK_PIPE_END_READ);
@@ -141,8 +142,7 @@ start_helper (const char *ifname,
   handle->mst = GNUNET_SERVER_mst_create (cb, cb_cls);
 
   GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                  handle->fh_from_helper, &helper_read,
-                                  handle);
+                                  handle->fh_from_helper, &helper_read, handle);
 
   return handle;
 }