X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Fclient.c;h=7e688059044211cebf40dcea045f51534252b4a0;hb=bb83cd2d04ff5a3f7a8d05fc9a724b0246e958b6;hp=171e9e957bb8d87146b3c6f2e5297d8b5779a93c;hpb=75a33a1499cf60ea4364c9aa673816629a6c1413;p=oweals%2Fgnunet.git diff --git a/src/util/client.c b/src/util/client.c index 171e9e957..7e6880590 100644 --- a/src/util/client.c +++ b/src/util/client.c @@ -43,7 +43,6 @@ */ #define MAX_ATTEMPTS 50 - /** * Handle for a transmission request. */ @@ -272,21 +271,28 @@ do_connect (const char *service_name, char *unixpath; unsigned long long port; + sock = NULL; #if AF_UNIX - if (0 == attempt % 2) + if (0 == (attempt % 2)) { /* on even rounds, try UNIX */ - if (GNUNET_OK == + if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, service_name, - "UNIXPATH", &unixpath)) + "UNIXPATH", &unixpath)) && + (0 < strlen (unixpath))) /* We have a non-NULL unixpath, does that mean it's valid? */ { - sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, - unixpath); - GNUNET_free (unixpath); + sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, unixpath); if (sock != NULL) - return sock; + { +#if DEBUG_CLIENT + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected to unixpath `%s'!\n", unixpath); +#endif + GNUNET_free(unixpath); + return sock; + } } + GNUNET_free_non_null (unixpath); } #endif @@ -302,8 +308,7 @@ do_connect (const char *service_name, "HOSTNAME", &hostname))) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _ - ("Could not determine valid hostname and port for service `%s' from configuration.\n"), + _("Could not determine valid hostname and port for service `%s' from configuration.\n"), service_name); return NULL; } @@ -315,6 +320,35 @@ do_connect (const char *service_name, service_name); return NULL; } + if (port == 0) + { +#if AF_UNIX + if (0 != (attempt % 2)) + { + /* try UNIX */ + if ((GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (cfg, + service_name, + "UNIXPATH", &unixpath)) && + (0 < strlen (unixpath))) + { + sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, + unixpath); + GNUNET_free (unixpath); + if (sock != NULL) + return sock; + } + } +#endif +#if DEBUG_CLIENT + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Port is 0 for service `%s', UNIXPATH did not work, returning NULL!\n", + service_name); +#endif + GNUNET_free (hostname); + return NULL; + } + sock = GNUNET_CONNECTION_create_from_connect (cfg, hostname, port); @@ -457,6 +491,9 @@ receive_helper (void *cls, if ((available == 0) || (conn->sock == NULL) || (errCode != 0)) { /* signal timeout! */ +#if DEBUG_CLIENT + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "timeout in receive_helper, available %d, conn->sock %s, errCode %d\n", available, conn->sock == NULL ? "NULL" : "non-NULL", errCode); +#endif if (NULL != (receive_handler = conn->receiver_handler)) { receive_handler_cls = conn->receiver_handler_cls; @@ -563,6 +600,9 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, { GNUNET_assert (sock->in_receive == GNUNET_NO); sock->in_receive = GNUNET_YES; +#if DEBUG_CLIENT + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "calling GNUNET_CONNECTION_receive\n"); +#endif GNUNET_CONNECTION_receive (sock->sock, GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, timeout, &receive_helper, sock);