gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: clean up arm, do not warn o


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: clean up arm, do not warn on missing port if autostart set
Date: Sat, 16 Jun 2018 10:38:33 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 50c2b2a28 clean up arm, do not warn on missing port if autostart set
50c2b2a28 is described below

commit 50c2b2a28aba97efbbd51658f18afda6d6ff7faa
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Jun 16 10:38:29 2018 +0200

    clean up arm, do not warn on missing port if autostart set
---
 src/arm/gnunet-service-arm.c | 148 ++++++++++++++++++++++++++++++-------------
 1 file changed, 103 insertions(+), 45 deletions(-)

diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 6924ca676..f7f51b31d 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -346,11 +346,15 @@ get_server_addresses (const char *service_name,
   *addrs = NULL;
   *addr_lens = NULL;
   desc = NULL;
-  if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "DISABLEV6"))
+  if (GNUNET_CONFIGURATION_have_value (cfg,
+                                      service_name,
+                                      "DISABLEV6"))
   {
     if (GNUNET_SYSERR ==
         (disablev6 =
-         GNUNET_CONFIGURATION_get_value_yesno (cfg, service_name, 
"DISABLEV6")))
+         GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                              service_name,
+                                              "DISABLEV6")))
       return GNUNET_SYSERR;
   }
   else
@@ -359,18 +363,24 @@ get_server_addresses (const char *service_name,
   if (! disablev6)
   {
     /* probe IPv6 support */
-    desc = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0);
+    desc = GNUNET_NETWORK_socket_create (PF_INET6,
+                                        SOCK_STREAM,
+                                        0);
     if (NULL == desc)
     {
-      if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
-          (EACCES == errno))
+      if ( (ENOBUFS == errno) ||
+          (ENOMEM == errno) ||
+          (ENFILE == errno) ||
+          (EACCES == errno) )
       {
-        LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket");
+        LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
+                     "socket");
         return GNUNET_SYSERR;
       }
       LOG (GNUNET_ERROR_TYPE_INFO,
            _("Disabling IPv6 support for service `%s', failed to create IPv6 
socket: %s\n"),
-           service_name, STRERROR (errno));
+           service_name,
+          STRERROR (errno));
       disablev6 = GNUNET_YES;
     }
     else
@@ -381,11 +391,15 @@ get_server_addresses (const char *service_name,
   }
 
   port = 0;
-  if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT"))
+  if (GNUNET_CONFIGURATION_have_value (cfg,
+                                      service_name,
+                                      "PORT"))
   {
     if (GNUNET_OK !=
-       GNUNET_CONFIGURATION_get_value_number (cfg, service_name,
-                                              "PORT", &port))
+       GNUNET_CONFIGURATION_get_value_number (cfg,
+                                              service_name,
+                                              "PORT",
+                                              &port))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
            _("Require valid port number for service `%s' in configuration!\n"),
@@ -400,11 +414,15 @@ get_server_addresses (const char *service_name,
     }
   }
 
-  if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO"))
+  if (GNUNET_CONFIGURATION_have_value (cfg,
+                                      service_name,
+                                      "BINDTO"))
   {
     GNUNET_break (GNUNET_OK ==
-                  GNUNET_CONFIGURATION_get_value_string (cfg, service_name,
-                                                         "BINDTO", &hostname));
+                  GNUNET_CONFIGURATION_get_value_string (cfg,
+                                                        service_name,
+                                                         "BINDTO",
+                                                        &hostname));
   }
   else
     hostname = NULL;
@@ -413,10 +431,14 @@ get_server_addresses (const char *service_name,
   abstract = GNUNET_NO;
 #ifdef AF_UNIX
   if ((GNUNET_YES ==
-       GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) &&
+       GNUNET_CONFIGURATION_have_value (cfg,
+                                       service_name,
+                                       "UNIXPATH")) &&
       (GNUNET_OK ==
-       GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH",
-                                              &unixpath)) &&
+       GNUNET_CONFIGURATION_get_value_filename (cfg,
+                                               service_name,
+                                               "UNIXPATH",
+                                               &unixpath)) &&
       (0 < strlen (unixpath)))
   {
     /* probe UNIX support */
@@ -425,7 +447,8 @@ get_server_addresses (const char *service_name,
     if (strlen (unixpath) >= sizeof (s_un.sun_path))
     {
       LOG (GNUNET_ERROR_TYPE_WARNING,
-           _("UNIXPATH `%s' too long, maximum length is %llu\n"), unixpath,
+           _("UNIXPATH `%s' too long, maximum length is %llu\n"),
+          unixpath,
            (unsigned long long) sizeof (s_un.sun_path));
       unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
       LOG (GNUNET_ERROR_TYPE_INFO,
@@ -439,9 +462,9 @@ get_server_addresses (const char *service_name,
     if (GNUNET_SYSERR == abstract)
       abstract = GNUNET_NO;
 #endif
-    if ((GNUNET_YES != abstract)
-        && (GNUNET_OK !=
-            GNUNET_DISK_directory_create_for_file (unixpath)))
+    if ( (GNUNET_YES != abstract) &&
+        (GNUNET_OK !=
+         GNUNET_DISK_directory_create_for_file (unixpath)) ) 
       GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
                                "mkdir",
                                unixpath);
@@ -451,8 +474,10 @@ get_server_addresses (const char *service_name,
     desc = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0);
     if (NULL == desc)
     {
-      if ((ENOBUFS == errno) || (ENOMEM == errno) || (ENFILE == errno) ||
-          (EACCES == errno))
+      if ( (ENOBUFS == errno) ||
+          (ENOMEM == errno) ||
+          (ENFILE == errno) ||
+          (EACCES == errno) )
       {
         LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "socket");
         GNUNET_free_non_null (hostname);
@@ -474,19 +499,29 @@ get_server_addresses (const char *service_name,
   }
 #endif
 
-  if ((0 == port) && (NULL == unixpath))
+  if ( (0 == port) &&
+       (NULL == unixpath) )
   {
-    LOG (GNUNET_ERROR_TYPE_ERROR,
-         _("Have neither PORT nor UNIXPATH for service `%s', but one is 
required\n"),
-         service_name);
+    if (GNUNET_YES !=
+        GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                              service_name,
+                                              "AUTOSTART"))
+      LOG (GNUNET_ERROR_TYPE_ERROR,
+          _("Have neither PORT nor UNIXPATH for service `%s', but one is 
required\n"),
+          service_name);
     GNUNET_free_non_null (hostname);
     return GNUNET_SYSERR;
   }
   if (0 == port)
   {
-    saddrs = GNUNET_malloc (2 * sizeof (struct sockaddr *));
-    saddrlens = GNUNET_malloc (2 * sizeof (socklen_t));
-    add_unixpath (saddrs, saddrlens, unixpath, abstract);
+    saddrs = GNUNET_new_array (2,
+                              struct sockaddr *);
+    saddrlens = GNUNET_new_array (2,
+                                 socklen_t);
+    add_unixpath (saddrs,
+                 saddrlens,
+                 unixpath,
+                 abstract);
     GNUNET_free_non_null (unixpath);
     GNUNET_free_non_null (hostname);
     *addrs = saddrs;
@@ -504,7 +539,10 @@ get_server_addresses (const char *service_name,
     if (disablev6)
       hints.ai_family = AF_INET;
     hints.ai_protocol = IPPROTO_TCP;
-    if ((0 != (ret = getaddrinfo (hostname, NULL, &hints, &res))) ||
+    if ((0 != (ret = getaddrinfo (hostname,
+                                 NULL,
+                                 &hints,
+                                 &res))) ||
         (NULL == res))
     {
       LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -538,8 +576,10 @@ get_server_addresses (const char *service_name,
     resi = i;
     if (NULL != unixpath)
       resi++;
-    saddrs = GNUNET_malloc ((resi + 1) * sizeof (struct sockaddr *));
-    saddrlens = GNUNET_malloc ((resi + 1) * sizeof (socklen_t));
+    saddrs = GNUNET_new_array (resi + 1,
+                              struct sockaddr *);
+    saddrlens = GNUNET_new_array (resi + 1,
+                                 socklen_t);
     i = 0;
     if (NULL != unixpath)
     {
@@ -591,8 +631,10 @@ get_server_addresses (const char *service_name,
       if (NULL != unixpath)
         resi++;
       i = 0;
-      saddrs = GNUNET_malloc ((resi + 1) * sizeof (struct sockaddr *));
-      saddrlens = GNUNET_malloc ((resi + 1) * sizeof (socklen_t));
+      saddrs = GNUNET_new_array (resi + 1,
+                                struct sockaddr *);
+      saddrlens = GNUNET_new_array (resi + 1,
+                                   socklen_t);
       if (NULL != unixpath)
       {
         add_unixpath (saddrs, saddrlens, unixpath, abstract);
@@ -612,12 +654,17 @@ get_server_addresses (const char *service_name,
       resi = 2;
       if (NULL != unixpath)
         resi++;
-      saddrs = GNUNET_malloc ((resi + 1) * sizeof (struct sockaddr *));
-      saddrlens = GNUNET_malloc ((resi + 1) * sizeof (socklen_t));
+      saddrs = GNUNET_new_array (resi + 1,
+                                struct sockaddr *);
+      saddrlens = GNUNET_new_array (resi + 1,
+                                   socklen_t);
       i = 0;
       if (NULL != unixpath)
       {
-        add_unixpath (saddrs, saddrlens, unixpath, abstract);
+        add_unixpath (saddrs,
+                     saddrlens,
+                     unixpath,
+                     abstract);
         i++;
       }
       saddrlens[i] = sizeof (struct sockaddr_in6);
@@ -663,6 +710,7 @@ signal_result (struct GNUNET_SERVICE_Client *client,
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_ARM_ResultMessage *msg;
 
+  (void) name;
   env = GNUNET_MQ_msg (msg,
                        GNUNET_MESSAGE_TYPE_ARM_RESULT);
   msg->result = htonl (result);
@@ -1184,6 +1232,7 @@ check_start (void *cls,
   uint16_t size;
   const char *servicename;
 
+  (void) cls;
   size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message);
   servicename = (const char *) &amsg[1];
   if ( (0 == size) ||
@@ -1254,6 +1303,7 @@ handle_start (void *cls,
 static void
 trigger_shutdown (void *cls)
 {
+  (void) cls;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Triggering shutdown\n");
   GNUNET_SCHEDULER_shutdown ();
@@ -1275,6 +1325,7 @@ check_stop (void *cls,
   uint16_t size;
   const char *servicename;
 
+  (void) cls;
   size = ntohs (amsg->header.size) - sizeof (struct GNUNET_ARM_Message);
   servicename = (const char *) &amsg[1];
   if ( (0 == size) ||
@@ -1451,6 +1502,7 @@ handle_test (void *cls,
   struct GNUNET_MQ_Envelope *env;
   struct GNUNET_MessageHeader *msg;
 
+  (void) message;
   env = GNUNET_MQ_msg (msg,
                        GNUNET_MESSAGE_TYPE_ARM_TEST);
   GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
@@ -1498,7 +1550,7 @@ list_count (struct ServiceList *running_head)
   struct ServiceList *i;
   unsigned int res;
 
-  for (res = 0, i = running_head; i; i = i->next, res++)
+  for (res = 0, i = running_head; NULL != i; i = i->next, res++)
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "%s\n",
                i->name);
@@ -1518,6 +1570,7 @@ shutdown_task (void *cls)
   struct ServiceList *nxt;
   struct ServiceListeningInfo *sli;
 
+  (void) cls;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "First shutdown phase\n");
   if (NULL != child_restart_task)
@@ -1589,6 +1642,7 @@ delayed_restart_task (void *cls)
   struct GNUNET_TIME_Relative lowestRestartDelay;
   struct ServiceListeningInfo *sli;
 
+  (void) cls;
   child_restart_task = NULL;
   GNUNET_assert (GNUNET_NO == in_shutdown);
   lowestRestartDelay = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -1656,7 +1710,7 @@ delayed_restart_task (void *cls)
  * Task triggered whenever we receive a SIGCHLD (child
  * process died).
  *
- * @param cls closure, NULL if we need to self-restart
+ * @param cls closure, NULL 
  */
 static void
 maint_child_death (void *cls)
@@ -1672,6 +1726,7 @@ maint_child_death (void *cls)
   unsigned long statusCode;
   const struct GNUNET_DISK_FileHandle *pr;
 
+  (void) cls;
   pr = GNUNET_DISK_pipe_handle (sigpipe,
                                GNUNET_DISK_PIPE_END_READ);
   child_death_task = NULL;
@@ -1914,6 +1969,7 @@ setup_service (void *cls,
   socklen_t *addr_lens;
   int ret;
 
+  (void) cls;
   if (0 == strcasecmp (section,
                        "arm"))
     return;
@@ -2024,7 +2080,7 @@ setup_service (void *cls,
                                        &addr_lens)))
     return;
   /* this will free (or capture) addrs[i] */
-  for (unsigned int i = 0; i < ret; i++)
+  for (unsigned int i = 0; i < (unsigned int) ret; i++)
     create_listen_socket (addrs[i],
                           addr_lens[i],
                           sl);
@@ -2049,6 +2105,8 @@ client_connect_cb (void *cls,
   /* All clients are considered to be of the "monitor" kind
    * (that is, they don't affect ARM shutdown).
    */
+  (void) cls;
+  (void) mq;
   GNUNET_SERVICE_client_mark_monitor (client);
   return client;
 }
@@ -2066,11 +2124,9 @@ client_disconnect_cb (void *cls,
                       struct GNUNET_SERVICE_Client *client,
                       void *app_ctx)
 {
-  struct ServiceList *sl;
-
+  (void) cls;
   GNUNET_assert (client == app_ctx);
-
-  for (sl = running_head; NULL != sl; sl = sl->next)
+  for (struct ServiceList *sl = running_head; NULL != sl; sl = sl->next)
     if (sl->killing_client == client)
       sl->killing_client = NULL;
 }
@@ -2090,6 +2146,7 @@ handle_monitor (void *cls,
 {
   struct GNUNET_SERVICE_Client *client = cls;
 
+  (void) message;
   /* FIXME: might want to start by letting monitor know about
      services that are already running */
   /* Removal is handled by the server implementation, internally. */
@@ -2105,7 +2162,7 @@ handle_monitor (void *cls,
 /**
  * Process arm requests.
  *
- * @param cls closure
+ * @param cls closure, NULL
  * @param serv the initialized service
  * @param c configuration to use
  */
@@ -2116,6 +2173,7 @@ run (void *cls,
 {
   struct ServiceList *sl;
 
+  (void) cls;
   cfg = c;
   service = serv;
   GNUNET_SCHEDULER_add_shutdown (&shutdown_task,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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