refuse to run if binds fail
authorChristian Grothoff <christian@grothoff.org>
Mon, 26 Sep 2016 16:15:07 +0000 (16:15 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 26 Sep 2016 16:15:07 +0000 (16:15 +0000)
src/util/service_new.c

index c15d981611124963f9b1844c54a1a559b5410558..95bdca33bbc7de35243b9bab6bbc25f5eb5e828e 100644 (file)
@@ -1279,13 +1279,25 @@ setup_service (struct GNUNET_SERVICE_Handle *sh)
       {
         GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
                              "bind");
+        GNUNET_free (addrs[i++]);
         GNUNET_free (slc);
         continue;
       }
+      GNUNET_free (addrs[i++]);
       GNUNET_CONTAINER_DLL_insert (sh->slc_head,
                                   sh->slc_tail,
                                   slc);
     }
+    GNUNET_free_non_null (addrlens);
+    GNUNET_free_non_null (addrs);
+    if ( (0 != num) &&
+         (NULL == sh->slc_head) )
+    {
+      /* All attempts to bind failed, hard failure */
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  _("Could not bind to any of the ports I was supposed to, refusing to run!\n"));
+      return GNUNET_SYSERR;
+    }
   }
 
   sh->require_found = tolerant ? GNUNET_NO : GNUNET_YES;