fix zombie-fest
authorChristian Grothoff <christian@grothoff.org>
Sun, 19 Feb 2017 12:57:34 +0000 (13:57 +0100)
committerChristian Grothoff <christian@grothoff.org>
Sun, 19 Feb 2017 12:57:34 +0000 (13:57 +0100)
src/include/gnunet_os_lib.h
src/nat/gnunet-service-nat_externalip.c
src/nat/gnunet-service-nat_mini.c

index ce3e05f13eed70f9887fb3583f9844a14cf4fa25..b3800f286282a639aaa5b8eb97894d7aa980725d 100644 (file)
@@ -381,7 +381,8 @@ GNUNET_OS_process_current (void);
  * @return 0 on success, -1 on error
  */
 int
-GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig);
+GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc,
+                        int sig);
 
 
 /**
index 979d2f0f5cc088d0e5751989f42a36b0c880d3a0..8df6f48a5381a3d3d89bd397bab5c6af9f94291a 100644 (file)
  *
  * This can be implemented using different methods, and we allow
  * the main service to be notified about changes to what we believe
- * is our external IPv4 address.  
+ * is our external IPv4 address.
  *
  * Note that this is explicitly only about NATed systems; if one
  * of our network interfaces has a global IP address this does
  * not count as "external".
  *
- * TODO:
- * - implement NEW logic for external IP detection based on traceroute!
- *
  * @file nat/gnunet-service-nat_externalip.c
  * @brief Functions for monitoring external IPv4 addresses
  * @author Christian Grothoff
@@ -86,7 +83,7 @@ struct GN_ExternalIPMonitor
    * Kept in DLL.
    */
   struct GN_ExternalIPMonitor *prev;
-  
+
   /**
    * Function to call when we believe our external IPv4 address changed.
    */
@@ -131,7 +128,7 @@ static struct in_addr mini_external_ipv4;
 /**
  * Tell relevant clients about a change in our external
  * IPv4 address.
- * 
+ *
  * @param add #GNUNET_YES to add, #GNUNET_NO to remove
  * @param v4 the external address that changed
  */
@@ -162,7 +159,7 @@ run_external_ip (void *cls);
  * We learn our current external IP address.  If it changed,
  * notify all of our applicable clients. Also re-schedule
  * #run_external_ip with an appropriate timeout.
- * 
+ *
  * @param cls NULL
  * @param addr the address, NULL on errors
  * @param result #GNUNET_NAT_ERROR_SUCCESS on success, otherwise the specific error code
@@ -173,7 +170,7 @@ handle_external_ip (void *cls,
                    enum GNUNET_NAT_StatusCode result)
 {
   char buf[INET_ADDRSTRLEN];
-  
+
   probe_external_ip_op = NULL;
   GNUNET_SCHEDULER_cancel (probe_external_ip_task);
   probe_external_ip_task
@@ -204,7 +201,7 @@ handle_external_ip (void *cls,
     if (0 != mini_external_ipv4.s_addr)
       notify_monitors_external_ipv4_change (GNUNET_NO,
                                            &mini_external_ipv4);
-    mini_external_ipv4.s_addr = 0; 
+    mini_external_ipv4.s_addr = 0;
     break;
   }
 }
@@ -254,7 +251,7 @@ GN_nat_status_changed (int have_nat)
                                  NULL);
     return;
   }
-  if (GNUNET_NO == have_nat) 
+  if (GNUNET_NO == have_nat)
   {
     if (NULL != probe_external_ip_task)
     {
index e5b9d021bf3136ce459d035bd2d8caf7588a054f..8f1229be17fceb24e8268a43f8fbb296f58240c8 100644 (file)
@@ -123,7 +123,7 @@ read_external_ipv4 (void *cls)
   {
     /* try to read more */
     eh->off += ret;
-    eh->task 
+    eh->task
       = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
                                        eh->r,
                                         &read_external_ipv4,
@@ -233,7 +233,7 @@ GNUNET_NAT_mini_get_external_ipv4_ (GNUNET_NAT_IPCallback cb,
                              GNUNET_DISK_PIPE_END_WRITE);
   eh->r = GNUNET_DISK_pipe_handle (eh->opipe,
                                   GNUNET_DISK_PIPE_END_READ);
-  eh->task 
+  eh->task
     = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
                                       eh->r,
                                       &read_external_ipv4,
@@ -254,6 +254,8 @@ GNUNET_NAT_mini_get_external_ipv4_cancel_ (struct GNUNET_NAT_ExternalHandle *eh)
   {
     (void) GNUNET_OS_process_kill (eh->eip,
                                   SIGKILL);
+    GNUNET_break (GNUNET_OK ==
+                  GNUNET_OS_process_wait (eh->eip));
     GNUNET_OS_process_destroy (eh->eip);
   }
   if (NULL != eh->opipe)
@@ -372,7 +374,7 @@ run_upnpc_r (struct GNUNET_NAT_MiniHandle *mini)
                    sizeof (pstr),
                    "%u",
                    (unsigned int) mini->port);
-  mini->map_cmd 
+  mini->map_cmd
     = GNUNET_OS_command_run (&process_map_output,
                             mini,
                             MAP_TIMEOUT,
@@ -516,7 +518,7 @@ do_refresh (void *cls)
   struct GNUNET_NAT_MiniHandle *mini = cls;
   int ac;
 
-  mini->refresh_task 
+  mini->refresh_task
     = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ,
                                    &do_refresh,
                                    mini);
@@ -538,7 +540,7 @@ do_refresh (void *cls)
     mini->refresh_cmd = NULL;
     ac = GNUNET_YES;
   }
-  mini->refresh_cmd 
+  mini->refresh_cmd
     = GNUNET_OS_command_run (&process_refresh_output,
                             mini,
                             MAP_TIMEOUT,
@@ -582,7 +584,7 @@ process_map_output (void *cls,
                0,
                 GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED);
     if (NULL == mini->refresh_task)
-      mini->refresh_task 
+      mini->refresh_task
         = GNUNET_SCHEDULER_add_delayed (MAP_REFRESH_FREQ,
                                        &do_refresh,
                                        mini);
@@ -747,7 +749,7 @@ GNUNET_NAT_mini_map_stop (struct GNUNET_NAT_MiniHandle *mini)
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Unmapping port %u with UPnP\n",
        ntohs (mini->current_addr.sin_port));
-  mini->unmap_cmd 
+  mini->unmap_cmd
     = GNUNET_OS_command_run (&process_unmap_output,
                             mini,
                             UNMAP_TIMEOUT,