- Allocate buffer large enough to contain UNIX_PATH_MAX size pathnames in case of...
[oweals/gnunet.git] / src / util / client.c
index fbdf881da49d69a4c5c911cbfcba3e9c8ca53125..02bec5a8f57e6c797b9f6ca5b5f2c9bceef11862 100644 (file)
@@ -548,7 +548,7 @@ receive_helper (void *cls, const void *buf, size_t available,
     if (NULL != (receive_handler = client->receiver_handler))
     {
       client->receiver_handler = NULL;
-      receiver_handler (client->receiver_handler_cls, NULL);
+      receive_handler (client->receiver_handler_cls, NULL);
     }
     return;
   }
@@ -576,8 +576,11 @@ receive_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   char mbuf[msize] GNUNET_ALIGN;
   struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) mbuf;
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received message of type %u and size %u from %s service.\n",
-       ntohs (cmsg->type), msize, client->service_name);
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Received message of type %u and size %u from %s service.\n",
+       ntohs (cmsg->type),
+       msize,
+       client->service_name);
   client->receive_task = GNUNET_SCHEDULER_NO_TASK;
   GNUNET_assert (GNUNET_YES == client->msg_complete);
   GNUNET_assert (client->received_pos >= msize);
@@ -839,6 +842,7 @@ GNUNET_CLIENT_service_test (const char *service,
     /* probe UNIX support */
     struct sockaddr_un s_un;
     char *unixpath;
+    int abstract;
 
     unixpath = NULL;
     if ((GNUNET_OK ==
@@ -859,17 +863,29 @@ GNUNET_CLIENT_service_test (const char *service,
              _("Using `%s' instead\n"), unixpath);
       }
     }
-    if (NULL != unixpath)
+#ifdef LINUX
+    abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+                                                     "TESTING",
+                                                     "USE_ABSTRACT_SOCKETS");
+#else
+    abstract = GNUNET_NO;
+#endif
+    if ((NULL != unixpath) && (GNUNET_YES != abstract))
     {
       if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (unixpath))
         GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
-            "mkdir", unixpath);
+                                  "mkdir", unixpath);
+    }
+    if (NULL != unixpath)
+    {
       sock = GNUNET_NETWORK_socket_create (PF_UNIX, SOCK_STREAM, 0);
       if (NULL != sock)
       {
        memset (&s_un, 0, sizeof (s_un));
        s_un.sun_family = AF_UNIX;
         strncpy (s_un.sun_path, unixpath, sizeof (s_un.sun_path) - 1);
+        if (GNUNET_YES == abstract)
+          s_un.sun_path[0] = '\0';
 #if HAVE_SOCKADDR_IN_SIN_LEN
         s_un.sun_len = (u_char) sizeof (struct sockaddr_un);
 #endif