diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-06-24 11:03:11 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-06-24 11:03:11 +0000 |
commit | 76259023a5566d42229a4a284616fa8bac93b6a5 (patch) | |
tree | 1bfe89a5a7ed226ba05e41e7fcbb369b98eec2d9 /src/dv/dv_api.c | |
parent | 551e4e177a8623ac35ece7125ec07de5f9b9d294 (diff) | |
download | gnunet-76259023a5566d42229a4a284616fa8bac93b6a5.tar.gz gnunet-76259023a5566d42229a4a284616fa8bac93b6a5.zip |
misc bugfixes, especially core dumps for dv test case
Diffstat (limited to 'src/dv/dv_api.c')
-rw-r--r-- | src/dv/dv_api.c | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index 9ab15ea62..8b92a703f 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c | |||
@@ -38,7 +38,9 @@ | |||
38 | #include "dv.h" | 38 | #include "dv.h" |
39 | #include "../transport/plugin_transport.h" | 39 | #include "../transport/plugin_transport.h" |
40 | 40 | ||
41 | 41 | /** | |
42 | * Store ready to send messages | ||
43 | */ | ||
42 | struct PendingMessages | 44 | struct PendingMessages |
43 | { | 45 | { |
44 | /** | 46 | /** |
@@ -58,8 +60,6 @@ struct PendingMessages | |||
58 | 60 | ||
59 | }; | 61 | }; |
60 | 62 | ||
61 | |||
62 | |||
63 | /** | 63 | /** |
64 | * Handle for the service. | 64 | * Handle for the service. |
65 | */ | 65 | */ |
@@ -96,11 +96,6 @@ struct GNUNET_DV_Handle | |||
96 | struct PendingMessages *current; | 96 | struct PendingMessages *current; |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Kill off the connection and any pending messages. | ||
100 | */ | ||
101 | int do_destroy; | ||
102 | |||
103 | /** | ||
104 | * Handler for messages we receive from the DV service | 99 | * Handler for messages we receive from the DV service |
105 | */ | 100 | */ |
106 | GNUNET_DV_MessageReceivedHandler receive_handler; | 101 | GNUNET_DV_MessageReceivedHandler receive_handler; |
@@ -171,6 +166,8 @@ hash_from_uid (uint32_t uid, | |||
171 | /** | 166 | /** |
172 | * Try to (re)connect to the dv service. | 167 | * Try to (re)connect to the dv service. |
173 | * | 168 | * |
169 | * @param ret handle to the (disconnected) dv service | ||
170 | * | ||
174 | * @return GNUNET_YES on success, GNUNET_NO on failure. | 171 | * @return GNUNET_YES on success, GNUNET_NO on failure. |
175 | */ | 172 | */ |
176 | static int | 173 | static int |
@@ -192,6 +189,9 @@ static void process_pending_message(struct GNUNET_DV_Handle *handle); | |||
192 | 189 | ||
193 | /** | 190 | /** |
194 | * Send complete, schedule next | 191 | * Send complete, schedule next |
192 | * | ||
193 | * @param handle handle to the dv service | ||
194 | * @param code return code for send (unused) | ||
195 | */ | 195 | */ |
196 | static void | 196 | static void |
197 | finish (struct GNUNET_DV_Handle *handle, int code) | 197 | finish (struct GNUNET_DV_Handle *handle, int code) |
@@ -204,7 +204,15 @@ finish (struct GNUNET_DV_Handle *handle, int code) | |||
204 | GNUNET_free (pos); | 204 | GNUNET_free (pos); |
205 | } | 205 | } |
206 | 206 | ||
207 | 207 | /** | |
208 | * Notification that we can send data | ||
209 | * | ||
210 | * @param cls handle to the dv service (struct GNUNET_DV_Handle) | ||
211 | * @param size how many bytes can we send | ||
212 | * @buf where to copy the message to send | ||
213 | * | ||
214 | * @return how many bytes we copied to buf | ||
215 | */ | ||
208 | static size_t | 216 | static size_t |
209 | transmit_pending (void *cls, size_t size, void *buf) | 217 | transmit_pending (void *cls, size_t size, void *buf) |
210 | { | 218 | { |
@@ -249,6 +257,8 @@ transmit_pending (void *cls, size_t size, void *buf) | |||
249 | 257 | ||
250 | /** | 258 | /** |
251 | * Try to send messages from list of messages to send | 259 | * Try to send messages from list of messages to send |
260 | * | ||
261 | * @param handle handle to the distance vector service | ||
252 | */ | 262 | */ |
253 | static void process_pending_message(struct GNUNET_DV_Handle *handle) | 263 | static void process_pending_message(struct GNUNET_DV_Handle *handle) |
254 | { | 264 | { |
@@ -265,11 +275,6 @@ static void process_pending_message(struct GNUNET_DV_Handle *handle) | |||
265 | handle->current = handle->pending_list; | 275 | handle->current = handle->pending_list; |
266 | if (NULL == handle->current) | 276 | if (NULL == handle->current) |
267 | { | 277 | { |
268 | if (handle->do_destroy) | ||
269 | { | ||
270 | handle->do_destroy = GNUNET_NO; | ||
271 | //GNUNET_DV_disconnect (handle); /* FIXME: replace with proper disconnect stuffs */ | ||
272 | } | ||
273 | return; | 278 | return; |
274 | } | 279 | } |
275 | handle->pending_list = handle->pending_list->next; | 280 | handle->pending_list = handle->pending_list->next; |
@@ -277,10 +282,10 @@ static void process_pending_message(struct GNUNET_DV_Handle *handle) | |||
277 | 282 | ||
278 | if (NULL == | 283 | if (NULL == |
279 | (handle->th = GNUNET_CLIENT_notify_transmit_ready (handle->client, | 284 | (handle->th = GNUNET_CLIENT_notify_transmit_ready (handle->client, |
280 | ntohl(handle->current->msg->msgbuf_size), | 285 | ntohs(handle->current->msg->header.size), |
281 | handle->current->msg->timeout, | 286 | handle->current->msg->timeout, |
282 | GNUNET_YES, | 287 | GNUNET_YES, |
283 | &transmit_pending, handle))) | 288 | &transmit_pending, handle))) |
284 | { | 289 | { |
285 | #if DEBUG_DV | 290 | #if DEBUG_DV |
286 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -456,7 +461,6 @@ int GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle, | |||
456 | msg->header.size = htons(msize); | 461 | msg->header.size = htons(msize); |
457 | msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND); | 462 | msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND); |
458 | memcpy(&msg->target, target, sizeof(struct GNUNET_PeerIdentity)); | 463 | memcpy(&msg->target, target, sizeof(struct GNUNET_PeerIdentity)); |
459 | msg->msgbuf_size = htonl(msgbuf_size); | ||
460 | msg->priority = htonl(priority); | 464 | msg->priority = htonl(priority); |
461 | msg->timeout = timeout; | 465 | msg->timeout = timeout; |
462 | msg->addrlen = htonl(addrlen); | 466 | msg->addrlen = htonl(addrlen); |
@@ -476,9 +480,16 @@ int GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle, | |||
476 | return GNUNET_OK; | 480 | return GNUNET_OK; |
477 | } | 481 | } |
478 | 482 | ||
479 | /* Forward declaration */ | 483 | /** |
480 | void GNUNET_DV_disconnect(struct GNUNET_DV_Handle *handle); | 484 | * Callback to transmit a start message to |
481 | 485 | * the DV service, once we can send | |
486 | * | ||
487 | * @param cls struct StartContext | ||
488 | * @param size how much can we send | ||
489 | * @param buf where to copy the message | ||
490 | * | ||
491 | * @return number of bytes copied to buf | ||
492 | */ | ||
482 | static size_t | 493 | static size_t |
483 | transmit_start (void *cls, size_t size, void *buf) | 494 | transmit_start (void *cls, size_t size, void *buf) |
484 | { | 495 | { |
@@ -531,7 +542,6 @@ GNUNET_DV_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
531 | handle->sched = sched; | 542 | handle->sched = sched; |
532 | handle->pending_list = NULL; | 543 | handle->pending_list = NULL; |
533 | handle->current = NULL; | 544 | handle->current = NULL; |
534 | handle->do_destroy = GNUNET_NO; | ||
535 | handle->th = NULL; | 545 | handle->th = NULL; |
536 | handle->client = GNUNET_CLIENT_connect(sched, "dv", cfg); | 546 | handle->client = GNUNET_CLIENT_connect(sched, "dv", cfg); |
537 | handle->receive_handler = receive_handler; | 547 | handle->receive_handler = receive_handler; |