diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-06-24 14:39:48 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-06-24 14:39:48 +0000 |
commit | 6dac089cef0a6e86128820423d7264864d2f34ad (patch) | |
tree | 4749511e60cb89c0192990c40ad49409c13af993 /src/dv/dv_api.c | |
parent | c9ccc2ff3d4549f726b3199cce296656a8cf313a (diff) | |
download | gnunet-6dac089cef0a6e86128820423d7264864d2f34ad.tar.gz gnunet-6dac089cef0a6e86128820423d7264864d2f34ad.zip |
move client listen call into transmit start callback, so we know service exists and is connected... otherwise we may stop listening before the service starts
Diffstat (limited to 'src/dv/dv_api.c')
-rw-r--r-- | src/dv/dv_api.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index 8b92a703f..dfc5a0fe9 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c | |||
@@ -178,7 +178,7 @@ try_connect (struct GNUNET_DV_Handle *ret) | |||
178 | ret->client = GNUNET_CLIENT_connect (ret->sched, "dv", ret->cfg); | 178 | ret->client = GNUNET_CLIENT_connect (ret->sched, "dv", ret->cfg); |
179 | if (ret->client != NULL) | 179 | if (ret->client != NULL) |
180 | return GNUNET_YES; | 180 | return GNUNET_YES; |
181 | #if DEBUG_STATISTICS | 181 | #if DEBUG_DV_MESSAGES |
182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 182 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
183 | _("Failed to connect to the dv service!\n")); | 183 | _("Failed to connect to the dv service!\n")); |
184 | #endif | 184 | #endif |
@@ -351,6 +351,9 @@ void handle_message_receipt (void *cls, | |||
351 | 351 | ||
352 | if (msg == NULL) | 352 | if (msg == NULL) |
353 | { | 353 | { |
354 | #if DEBUG_DV_MESSAGES | ||
355 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: connection closed\n"); | ||
356 | #endif | ||
354 | return; /* Connection closed? */ | 357 | return; /* Connection closed? */ |
355 | } | 358 | } |
356 | 359 | ||
@@ -373,7 +376,7 @@ void handle_message_receipt (void *cls, | |||
373 | packed_msg = GNUNET_malloc(packed_msg_len); | 376 | packed_msg = GNUNET_malloc(packed_msg_len); |
374 | memcpy(packed_msg, &packed_msg_start[sender_address_len], packed_msg_len); | 377 | memcpy(packed_msg, &packed_msg_start[sender_address_len], packed_msg_len); |
375 | 378 | ||
376 | #if DEBUG_DV | 379 | #if DEBUG_DV_MESSAGES |
377 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: packed message type: %d or %d\n", ntohs(((struct GNUNET_MessageHeader *)packed_msg)->type), ((struct GNUNET_MessageHeader *)packed_msg)->type); | 380 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: packed message type: %d or %d\n", ntohs(((struct GNUNET_MessageHeader *)packed_msg)->type), ((struct GNUNET_MessageHeader *)packed_msg)->type); |
378 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: message sender reported as %s\n", GNUNET_i2s(&received_msg->sender)); | 381 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: message sender reported as %s\n", GNUNET_i2s(&received_msg->sender)); |
379 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: distance is %u\n", ntohl(received_msg->distance)); | 382 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: distance is %u\n", ntohl(received_msg->distance)); |
@@ -496,7 +499,9 @@ transmit_start (void *cls, size_t size, void *buf) | |||
496 | struct StartContext *start_context = cls; | 499 | struct StartContext *start_context = cls; |
497 | struct GNUNET_DV_Handle *handle = start_context->handle; | 500 | struct GNUNET_DV_Handle *handle = start_context->handle; |
498 | size_t tsize; | 501 | size_t tsize; |
499 | 502 | #if DEBUG_DV | |
503 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV API: sending start request to service\n"); | ||
504 | #endif | ||
500 | if (buf == NULL) | 505 | if (buf == NULL) |
501 | { | 506 | { |
502 | GNUNET_free(start_context->message); | 507 | GNUNET_free(start_context->message); |
@@ -511,6 +516,11 @@ transmit_start (void *cls, size_t size, void *buf) | |||
511 | memcpy(buf, start_context->message, tsize); | 516 | memcpy(buf, start_context->message, tsize); |
512 | GNUNET_free(start_context->message); | 517 | GNUNET_free(start_context->message); |
513 | GNUNET_free(start_context); | 518 | GNUNET_free(start_context); |
519 | GNUNET_CLIENT_receive (handle->client, | ||
520 | &handle_message_receipt, | ||
521 | handle, GNUNET_TIME_UNIT_FOREVER_REL); | ||
522 | |||
523 | |||
514 | return tsize; | 524 | return tsize; |
515 | } | 525 | } |
516 | 526 | ||
@@ -568,10 +578,6 @@ GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
568 | 578 | ||
569 | handle->send_callbacks = GNUNET_CONTAINER_multihashmap_create(100); | 579 | handle->send_callbacks = GNUNET_CONTAINER_multihashmap_create(100); |
570 | 580 | ||
571 | GNUNET_CLIENT_receive (handle->client, | ||
572 | &handle_message_receipt, | ||
573 | handle, GNUNET_TIME_UNIT_FOREVER_REL); | ||
574 | |||
575 | return handle; | 581 | return handle; |
576 | } | 582 | } |
577 | 583 | ||