diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-25 15:47:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-25 15:47:40 +0000 |
commit | 507d63234ac7ff86f0cff179637f5a07f6075768 (patch) | |
tree | 718e4951d8c9a84c980f4f260400efbc7bbd1b78 /src/util/connection.c | |
parent | c3d761427386b2a48fbd3e5bc07248e5d038ab2c (diff) | |
download | gnunet-507d63234ac7ff86f0cff179637f5a07f6075768.tar.gz gnunet-507d63234ac7ff86f0cff179637f5a07f6075768.zip |
handle errors better
Diffstat (limited to 'src/util/connection.c')
-rw-r--r-- | src/util/connection.c | 25 |
1 files changed, 16 insertions, 9 deletions
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 | |||
290 | * termination as a signal (because only then will the leaked | 290 | * termination as a signal (because only then will the leaked |
291 | * socket be freed!) | 291 | * socket be freed!) |
292 | */ | 292 | */ |
293 | int persist; | 293 | int16_t persist; |
294 | 294 | ||
295 | }; | 295 | }; |
296 | 296 | ||
@@ -1345,6 +1345,13 @@ transmit_error (struct GNUNET_CONNECTION_Handle *sock) | |||
1345 | { | 1345 | { |
1346 | GNUNET_CONNECTION_TransmitReadyNotify notify; | 1346 | GNUNET_CONNECTION_TransmitReadyNotify notify; |
1347 | 1347 | ||
1348 | if (NULL != sock->sock) | ||
1349 | { | ||
1350 | GNUNET_NETWORK_socket_shutdown (sock->sock, SHUT_RDWR); | ||
1351 | GNUNET_break (GNUNET_OK == | ||
1352 | GNUNET_NETWORK_socket_close (sock->sock)); | ||
1353 | sock->sock = NULL; | ||
1354 | } | ||
1348 | if (sock->nth.notify_ready == NULL) | 1355 | if (sock->nth.notify_ready == NULL) |
1349 | return; /* nobody to tell about it */ | 1356 | return; /* nobody to tell about it */ |
1350 | notify = sock->nth.notify_ready; | 1357 | notify = sock->nth.notify_ready; |
@@ -1418,13 +1425,6 @@ transmit_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1418 | ("Could not satisfy pending transmission request, socket closed or connect failed (%p).\n"), | 1425 | ("Could not satisfy pending transmission request, socket closed or connect failed (%p).\n"), |
1419 | sock); | 1426 | sock); |
1420 | #endif | 1427 | #endif |
1421 | if (NULL != sock->sock) | ||
1422 | { | ||
1423 | GNUNET_NETWORK_socket_shutdown (sock->sock, SHUT_RDWR); | ||
1424 | GNUNET_break (GNUNET_OK == | ||
1425 | GNUNET_NETWORK_socket_close (sock->sock)); | ||
1426 | sock->sock = NULL; | ||
1427 | } | ||
1428 | transmit_error (sock); | 1428 | transmit_error (sock); |
1429 | return; /* connect failed for good, we're finished */ | 1429 | return; /* connect failed for good, we're finished */ |
1430 | } | 1430 | } |
@@ -1448,10 +1448,17 @@ RETRY: | |||
1448 | { | 1448 | { |
1449 | if (errno == EINTR) | 1449 | if (errno == EINTR) |
1450 | goto RETRY; | 1450 | goto RETRY; |
1451 | #if 0 | ||
1452 | int en = errno; | ||
1453 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1454 | _("Failed to send to `%s': %s\n"), | ||
1455 | GNUNET_a2s (sock->addr, | ||
1456 | sock->addrlen), | ||
1457 | STRERROR (en)); | ||
1458 | #endif | ||
1451 | #if DEBUG_CONNECTION | 1459 | #if DEBUG_CONNECTION |
1452 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send"); | 1460 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "send"); |
1453 | #endif | 1461 | #endif |
1454 | GNUNET_NETWORK_socket_shutdown (sock->sock, SHUT_WR); | ||
1455 | transmit_error (sock); | 1462 | transmit_error (sock); |
1456 | return; | 1463 | return; |
1457 | } | 1464 | } |