diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-01-31 11:22:23 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-01-31 11:22:23 +0000 |
commit | 58e5ef6d095284050a9e0f9d79ac8008c2fab714 (patch) | |
tree | 6c82ac17c0cd2c2c710940fd0bf268e6d3c4d90f /src/util | |
parent | 7e739d9fc537d18ca78ba61135669044ec32c4c2 (diff) | |
download | gnunet-58e5ef6d095284050a9e0f9d79ac8008c2fab714.tar.gz gnunet-58e5ef6d095284050a9e0f9d79ac8008c2fab714.zip |
Fix for unixpath/arm bug
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/client.c | 39 | ||||
-rw-r--r-- | src/util/connection.c | 12 |
2 files changed, 43 insertions, 8 deletions
diff --git a/src/util/client.c b/src/util/client.c index 257a69b5a..a097086d3 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -43,6 +43,8 @@ | |||
43 | */ | 43 | */ |
44 | #define MAX_ATTEMPTS 50 | 44 | #define MAX_ATTEMPTS 50 |
45 | 45 | ||
46 | #define UNIXPATH_RETRIES 0 | ||
47 | |||
46 | 48 | ||
47 | /** | 49 | /** |
48 | * Handle for a transmission request. | 50 | * Handle for a transmission request. |
@@ -271,7 +273,9 @@ do_connect (const char *service_name, | |||
271 | char *hostname; | 273 | char *hostname; |
272 | char *unixpath; | 274 | char *unixpath; |
273 | unsigned long long port; | 275 | unsigned long long port; |
276 | unsigned int count; | ||
274 | 277 | ||
278 | sock = NULL; | ||
275 | #if AF_UNIX | 279 | #if AF_UNIX |
276 | if (0 == (attempt % 2)) | 280 | if (0 == (attempt % 2)) |
277 | { | 281 | { |
@@ -280,13 +284,28 @@ do_connect (const char *service_name, | |||
280 | GNUNET_CONFIGURATION_get_value_string (cfg, | 284 | GNUNET_CONFIGURATION_get_value_string (cfg, |
281 | service_name, | 285 | service_name, |
282 | "UNIXPATH", &unixpath)) && | 286 | "UNIXPATH", &unixpath)) && |
283 | (0 < strlen (unixpath))) | 287 | (0 < strlen (unixpath))) /* We have a non-NULL unixpath, does that mean it's valid? */ |
284 | { | 288 | { |
285 | sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, | 289 | count = 0; |
286 | unixpath); | 290 | sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, unixpath); |
291 | while ((NULL == sock) && (count < UNIXPATH_RETRIES)) | ||
292 | { | ||
293 | #if DEBUG_CLIENT | ||
294 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Failed to connect to unixpath `%s', retrying!\n", unixpath); | ||
295 | #endif | ||
296 | count++; | ||
297 | sleep(1); | ||
298 | sock = GNUNET_CONNECTION_create_from_connect_to_unixpath (cfg, unixpath); | ||
299 | } | ||
300 | |||
287 | GNUNET_free (unixpath); | 301 | GNUNET_free (unixpath); |
288 | if (sock != NULL) | 302 | if (sock != NULL) |
289 | return sock; | 303 | { |
304 | #if DEBUG_CLIENT | ||
305 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Connected to unixpath `%s'!\n", unixpath); | ||
306 | #endif | ||
307 | return sock; | ||
308 | } | ||
290 | } | 309 | } |
291 | } | 310 | } |
292 | #endif | 311 | #endif |
@@ -332,12 +351,16 @@ do_connect (const char *service_name, | |||
332 | unixpath); | 351 | unixpath); |
333 | GNUNET_free (unixpath); | 352 | GNUNET_free (unixpath); |
334 | if (sock != NULL) | 353 | if (sock != NULL) |
335 | return sock; | 354 | { |
355 | return sock; | ||
356 | } | ||
336 | } | 357 | } |
337 | } | 358 | } |
338 | #endif | 359 | #endif |
360 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Port is 0 for service `%s', unixpath didn't work, returning NULL(!)!\n", service_name); | ||
339 | return NULL; | 361 | return NULL; |
340 | } | 362 | } |
363 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Creating from connect!\n"); | ||
341 | sock = GNUNET_CONNECTION_create_from_connect (cfg, | 364 | sock = GNUNET_CONNECTION_create_from_connect (cfg, |
342 | hostname, | 365 | hostname, |
343 | port); | 366 | port); |
@@ -480,6 +503,9 @@ receive_helper (void *cls, | |||
480 | if ((available == 0) || (conn->sock == NULL) || (errCode != 0)) | 503 | if ((available == 0) || (conn->sock == NULL) || (errCode != 0)) |
481 | { | 504 | { |
482 | /* signal timeout! */ | 505 | /* signal timeout! */ |
506 | #if DEBUG_CLIENT | ||
507 | 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); | ||
508 | #endif | ||
483 | if (NULL != (receive_handler = conn->receiver_handler)) | 509 | if (NULL != (receive_handler = conn->receiver_handler)) |
484 | { | 510 | { |
485 | receive_handler_cls = conn->receiver_handler_cls; | 511 | receive_handler_cls = conn->receiver_handler_cls; |
@@ -586,6 +612,9 @@ GNUNET_CLIENT_receive (struct GNUNET_CLIENT_Connection *sock, | |||
586 | { | 612 | { |
587 | GNUNET_assert (sock->in_receive == GNUNET_NO); | 613 | GNUNET_assert (sock->in_receive == GNUNET_NO); |
588 | sock->in_receive = GNUNET_YES; | 614 | sock->in_receive = GNUNET_YES; |
615 | #if DEBUG_CLIENT | ||
616 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "calling GNUNET_CONNECTION_receive\n"); | ||
617 | #endif | ||
589 | GNUNET_CONNECTION_receive (sock->sock, | 618 | GNUNET_CONNECTION_receive (sock->sock, |
590 | GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, | 619 | GNUNET_SERVER_MAX_MESSAGE_SIZE - 1, |
591 | timeout, &receive_helper, sock); | 620 | timeout, &receive_helper, sock); |
diff --git a/src/util/connection.c b/src/util/connection.c index b0504ddd8..095fddb45 100644 --- a/src/util/connection.c +++ b/src/util/connection.c | |||
@@ -41,6 +41,8 @@ | |||
41 | 41 | ||
42 | #define DEBUG_CONNECTION GNUNET_NO | 42 | #define DEBUG_CONNECTION GNUNET_NO |
43 | 43 | ||
44 | #define HARD_FAIL GNUNET_NO | ||
45 | |||
44 | 46 | ||
45 | /** | 47 | /** |
46 | * Possible functions to call after connect failed or succeeded. | 48 | * Possible functions to call after connect failed or succeeded. |
@@ -965,14 +967,16 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct | |||
965 | ret->addr, | 967 | ret->addr, |
966 | ret->addrlen)) | 968 | ret->addrlen)) |
967 | { | 969 | { |
968 | /* Just return; we expect everything to work eventually so don't fail HARD */ | ||
969 | return ret; | ||
970 | #if HARD_FAIL | 970 | #if HARD_FAIL |
971 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ret->sock)); | 971 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ret->sock)); |
972 | GNUNET_free (ret->addr); | 972 | GNUNET_free (ret->addr); |
973 | GNUNET_free (ret->write_buffer); | 973 | GNUNET_free (ret->write_buffer); |
974 | GNUNET_free (ret); | 974 | GNUNET_free (ret); |
975 | return NULL; | 975 | return NULL; |
976 | #else /* Just return; we expect everything to work eventually so don't fail HARD */ | ||
977 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ret->sock)); | ||
978 | ret->sock = NULL; | ||
979 | return ret; | ||
976 | #endif | 980 | #endif |
977 | } | 981 | } |
978 | connect_success_continuation (ret); | 982 | connect_success_continuation (ret); |
@@ -1415,7 +1419,9 @@ connect_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1415 | { | 1419 | { |
1416 | struct GNUNET_CONNECTION_Handle *sock = cls; | 1420 | struct GNUNET_CONNECTION_Handle *sock = cls; |
1417 | GNUNET_CONNECTION_TransmitReadyNotify notify; | 1421 | GNUNET_CONNECTION_TransmitReadyNotify notify; |
1418 | 1422 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
1423 | "Transmission request of size %u fails, connection failed (%p).\n", | ||
1424 | sock->nth.notify_size, sock); | ||
1419 | #if DEBUG_CONNECTION | 1425 | #if DEBUG_CONNECTION |
1420 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1426 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1421 | "Transmission request of size %u fails, connection failed (%p).\n", | 1427 | "Transmission request of size %u fails, connection failed (%p).\n", |