MinGW
[oweals/gnunet.git] / src / util / service.c
index b4e4a552829737016695da5c593b5be80c2af83e..e6fec7514b6b8d9ef513fc4ac92097d741696f0e 100644 (file)
@@ -781,7 +781,6 @@ GNUNET_SERVICE_get_server_addresses (const char *serviceName,
 
   *addrs = NULL;
   *addr_lens = NULL;
-  resi = 0;
   if (GNUNET_CONFIGURATION_have_value (cfg,
                                        serviceName, "DISABLEV6"))
     {
@@ -1000,8 +999,13 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
           GNUNET_CONFIGURATION_get_value_time (sctx->cfg,
                                                sctx->serviceName,
                                                "TIMEOUT", &idleout))
-        return GNUNET_SYSERR;
-
+       {
+         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     _("Specified value for `%s' of service `%s' is invalid\n"),
+                     "TIMEOUT",
+                     sctx->serviceName);
+         return GNUNET_SYSERR;
+       }
       sctx->timeout = idleout;
     }
   else
@@ -1013,7 +1017,13 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
           GNUNET_CONFIGURATION_get_value_number (sctx->cfg,
                                                  sctx->serviceName,
                                                  "MAXBUF", &maxbuf))
-        return GNUNET_SYSERR;
+       {
+         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     _("Specified value for `%s' of service `%s' is invalid\n"),
+                     "MAXBUF",
+                     sctx->serviceName);
+         return GNUNET_SYSERR;
+       }
     }
   else
     maxbuf = GNUNET_SERVER_MAX_MESSAGE_SIZE;
@@ -1024,7 +1034,13 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
           (sctx->allow_shutdown =
            GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->serviceName,
                                                  "ALLOW_SHUTDOWN")))
-        return GNUNET_SYSERR;
+       {
+         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     _("Specified value for `%s' of service `%s' is invalid\n"),
+                     "ALLOW_SHUTDOWN",
+                     sctx->serviceName);
+         return GNUNET_SYSERR;
+       }
     }
   else
     sctx->allow_shutdown = GNUNET_NO;
@@ -1037,7 +1053,13 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
           (tolerant = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg,
                                                             sctx->serviceName,
                                                             "TOLERANT")))
-        return GNUNET_SYSERR;
+       {
+         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     _("Specified value for `%s' of service `%s' is invalid\n"),
+                     "TOLERANT",
+                     sctx->serviceName);
+         return GNUNET_SYSERR;
+       }
     }
   else
     tolerant = GNUNET_NO;
@@ -1405,7 +1427,7 @@ GNUNET_SERVICE_run (int argc,
   do_daemonize = 0;
   logfile = NULL;
   loglev = GNUNET_strdup ("WARNING");
-  cfg_fn = GNUNET_strdup (GNUNET_DEFAULT_DAEMON_CONFIG_FILE);
+  cfg_fn = GNUNET_strdup (GNUNET_DEFAULT_USER_CONFIG_FILE);
   memset (&sctx, 0, sizeof (sctx));
   sctx.options = opt;
   sctx.ready_confirm_fd = -1;
@@ -1418,17 +1440,17 @@ GNUNET_SERVICE_run (int argc,
   /* setup subsystems */
   if (GNUNET_SYSERR == GNUNET_GETOPT_run (serviceName, service_options, argc,
       argv))    
-    HANDLE_ERROR;
+    goto shutdown;
   if (GNUNET_OK != GNUNET_log_setup (serviceName, loglev, logfile))
     HANDLE_ERROR;
   if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfg_fn))
-    HANDLE_ERROR;
+    goto shutdown;
   if (GNUNET_OK != setup_service (&sctx))
-    HANDLE_ERROR;
+    goto shutdown;
   if ( (do_daemonize == 1) && (GNUNET_OK != detach_terminal (&sctx)))    
     HANDLE_ERROR;
   if (GNUNET_OK != set_user_id (&sctx))
-    HANDLE_ERROR;
+    goto shutdown;
 #if DEBUG_SERVICE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Service `%s' runs with configuration from `%s'\n",
@@ -1452,8 +1474,9 @@ shutdown:
 
   GNUNET_CONFIGURATION_destroy (cfg);
   i = 0;
-  while (sctx.addrs[i] != NULL)    
-    GNUNET_free (sctx.addrs[i++]);    
+  if (sctx.addrs != NULL)
+    while (sctx.addrs[i] != NULL)    
+      GNUNET_free (sctx.addrs[i++]);    
   GNUNET_free_non_null (sctx.addrs);
   GNUNET_free_non_null (sctx.addrlens);
   GNUNET_free_non_null (logfile);