api work
[oweals/gnunet.git] / src / util / service.c
index 8d72a749a4f55860f68ff62348946d80e7a2790d..0569a0fde698c079a56da25a1d75feb7071dcdce 100644 (file)
@@ -754,7 +754,7 @@ static int
 setup_service (struct GNUNET_SERVICE_Context *sctx)
 {
   unsigned long long maxbuf;
-  unsigned long long idleout;
+  struct GNUNET_TIME_Relative idleout;
   char *hostname;
   unsigned long long port;
   int disablev6;
@@ -768,12 +768,12 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
                                        sctx->serviceName, "TIMEOUT"))
     {
       if (GNUNET_OK !=
-          GNUNET_CONFIGURATION_get_value_number (sctx->cfg,
-                                                 sctx->serviceName,
-                                                 "TIMEOUT", &idleout))
+          GNUNET_CONFIGURATION_get_value_time (sctx->cfg,
+                                              sctx->serviceName,
+                                              "TIMEOUT", &idleout))
         return GNUNET_SYSERR;
 
-      sctx->timeout.value = idleout;
+      sctx->timeout = idleout;
     }
   else
     sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
@@ -900,7 +900,8 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
       if (pos == NULL)
         {
           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                      _("Failed to find IPv4 address for `%s'.\n"), hostname);
+                      _("Failed to find %saddress for `%s'.\n"),
+                     disablev6 ? "IPv4 " : "", hostname);
           freeaddrinfo (res);
           GNUNET_free (hostname);
           return GNUNET_SYSERR;
@@ -924,6 +925,7 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
           GNUNET_assert (pos->ai_addrlen == sizeof (struct sockaddr_in6));
           sctx->addrlen = pos->ai_addrlen;
           sctx->addr = GNUNET_malloc (sctx->addrlen);
+          memcpy (sctx->addr, res->ai_addr, sctx->addrlen);
           GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                       _
                       ("Configured to bind to %s address; %s connections to this service will fail!\n"),
@@ -1154,7 +1156,7 @@ detach_terminal (struct GNUNET_SERVICE_Context *sctx)
   GNUNET_break (0 == CLOSE (0));
   GNUNET_break (0 == CLOSE (1));
   GNUNET_break (0 == CLOSE (filedes[0]));
-  nullfd = GNUNET_DISK_file_open ("/dev/null", O_RDWR | O_APPEND);
+  nullfd = OPEN ("/dev/null", O_RDWR | O_APPEND);
   if (nullfd < 0)
     return GNUNET_SYSERR;
   /* set stdin/stdout to /dev/null */