From: Christian Grothoff Date: Tue, 25 May 2010 15:47:40 +0000 (+0000) Subject: handle errors better X-Git-Tag: initial-import-from-subversion-38251~21582 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=507d63234ac7ff86f0cff179637f5a07f6075768;p=oweals%2Fgnunet.git handle errors better --- diff --git a/src/util/connection.c b/src/util/connection.c index d2d4432c6..290a361b3 100644 --- a/src/util/connection.c +++ b/src/util/connection.c @@ -290,7 +290,7 @@ struct GNUNET_CONNECTION_Handle * termination as a signal (because only then will the leaked * socket be freed!) */ - int persist; + int16_t persist; }; @@ -1345,6 +1345,13 @@ transmit_error (struct GNUNET_CONNECTION_Handle *sock) { GNUNET_CONNECTION_TransmitReadyNotify notify; + if (NULL != sock->sock) + { + GNUNET_NETWORK_socket_shutdown (sock->sock, SHUT_RDWR); + GNUNET_break (GNUNET_OK == + GNUNET_NETWORK_socket_close (sock->sock)); + sock->sock = NULL; + } if (sock->nth.notify_ready == NULL) return; /* nobody to tell about it */ notify = sock->nth.notify_ready; @@ -1418,13 +1425,6 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) ("Could not satisfy pending transmission request, socket closed or connect failed (%p).\n"), sock); #endif - if (NULL != sock->sock) - { - GNUNET_NETWORK_socket_shutdown (sock->sock, SHUT_RDWR); - GNUNET_break (GNUNET_OK == - GNUNET_NETWORK_socket_close (sock->sock)); - sock->sock = NULL; - } transmit_error (sock); return; /* connect failed for good, we're finished */ } @@ -1448,10 +1448,17 @@ RETRY: { if (errno == EINTR) goto RETRY; +#if 0 + int en = errno; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Failed to send to `%s': %s\n"), + GNUNET_a2s (sock->addr, + sock->addrlen), + STRERROR (en)); +#endif #if DEBUG_CONNECTION GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send"); #endif - GNUNET_NETWORK_socket_shutdown (sock->sock, SHUT_WR); transmit_error (sock); return; }