diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/client.c | 41 | ||||
-rw-r--r-- | src/util/mq.c | 22 | ||||
-rw-r--r-- | src/util/mst.c | 27 | ||||
-rw-r--r-- | src/util/scheduler.c | 4 | ||||
-rw-r--r-- | src/util/service.c | 31 |
5 files changed, 110 insertions, 15 deletions
diff --git a/src/util/client.c b/src/util/client.c index 3d74bff33..e5bf7e176 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -261,14 +261,27 @@ transmit_ready (void *cls) | |||
261 | pos = (const char *) cstate->msg; | 261 | pos = (const char *) cstate->msg; |
262 | len = ntohs (cstate->msg->size); | 262 | len = ntohs (cstate->msg->size); |
263 | GNUNET_assert (cstate->msg_off < len); | 263 | GNUNET_assert (cstate->msg_off < len); |
264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
265 | "client: message of type %u trying to send with socket %p (MQ: %p\n", | ||
266 | ntohs(cstate->msg->type), | ||
267 | cstate->sock, | ||
268 | cstate->mq); | ||
269 | |||
264 | RETRY: | 270 | RETRY: |
265 | ret = GNUNET_NETWORK_socket_send (cstate->sock, | 271 | ret = GNUNET_NETWORK_socket_send (cstate->sock, |
266 | &pos[cstate->msg_off], | 272 | &pos[cstate->msg_off], |
267 | len - cstate->msg_off); | 273 | len - cstate->msg_off); |
268 | if (-1 == ret) | 274 | if (-1 == ret) |
269 | { | 275 | { |
270 | if (EINTR == errno) | 276 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
277 | "client: error during sending message of type %u\n", | ||
278 | ntohs(cstate->msg->type)); | ||
279 | if (EINTR == errno){ | ||
280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
281 | "client: retrying message of type %u\n", | ||
282 | ntohs(cstate->msg->type)); | ||
271 | goto RETRY; | 283 | goto RETRY; |
284 | } | ||
272 | GNUNET_MQ_inject_error (cstate->mq, | 285 | GNUNET_MQ_inject_error (cstate->mq, |
273 | GNUNET_MQ_ERROR_WRITE); | 286 | GNUNET_MQ_ERROR_WRITE); |
274 | return; | 287 | return; |
@@ -277,6 +290,9 @@ transmit_ready (void *cls) | |||
277 | cstate->msg_off += ret; | 290 | cstate->msg_off += ret; |
278 | if (cstate->msg_off < len) | 291 | if (cstate->msg_off < len) |
279 | { | 292 | { |
293 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
294 | "client: rescheduling message of type %u\n", | ||
295 | ntohs(cstate->msg->type)); | ||
280 | cstate->send_task | 296 | cstate->send_task |
281 | = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, | 297 | = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, |
282 | cstate->sock, | 298 | cstate->sock, |
@@ -286,6 +302,9 @@ transmit_ready (void *cls) | |||
286 | GNUNET_MQ_impl_send_in_flight (cstate->mq); | 302 | GNUNET_MQ_impl_send_in_flight (cstate->mq); |
287 | return; | 303 | return; |
288 | } | 304 | } |
305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
306 | "client: sending message of type %u successful\n", | ||
307 | ntohs(cstate->msg->type)); | ||
289 | cstate->msg = NULL; | 308 | cstate->msg = NULL; |
290 | GNUNET_MQ_impl_send_continue (cstate->mq); | 309 | GNUNET_MQ_impl_send_continue (cstate->mq); |
291 | } | 310 | } |
@@ -297,7 +316,9 @@ transmit_ready (void *cls) | |||
297 | * | 316 | * |
298 | * @param cls the `struct ClientState` | 317 | * @param cls the `struct ClientState` |
299 | * @param msg message we received. | 318 | * @param msg message we received. |
300 | * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing | 319 | * @return #GNUNET_OK on success, |
320 | * #GNUNET_NO to stop further processing due to disconnect (no error) | ||
321 | * #GNUNET_SYSERR to stop further processing due to error | ||
301 | */ | 322 | */ |
302 | static int | 323 | static int |
303 | recv_message (void *cls, | 324 | recv_message (void *cls, |
@@ -306,7 +327,7 @@ recv_message (void *cls, | |||
306 | struct ClientState *cstate = cls; | 327 | struct ClientState *cstate = cls; |
307 | 328 | ||
308 | if (GNUNET_YES == cstate->in_destroy) | 329 | if (GNUNET_YES == cstate->in_destroy) |
309 | return GNUNET_SYSERR; | 330 | return GNUNET_NO; |
310 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 331 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
311 | "Received message of type %u and size %u from %s\n", | 332 | "Received message of type %u and size %u from %s\n", |
312 | ntohs (msg->type), | 333 | ntohs (msg->type), |
@@ -315,7 +336,7 @@ recv_message (void *cls, | |||
315 | GNUNET_MQ_inject_message (cstate->mq, | 336 | GNUNET_MQ_inject_message (cstate->mq, |
316 | msg); | 337 | msg); |
317 | if (GNUNET_YES == cstate->in_destroy) | 338 | if (GNUNET_YES == cstate->in_destroy) |
318 | return GNUNET_SYSERR; | 339 | return GNUNET_NO; |
319 | return GNUNET_OK; | 340 | return GNUNET_OK; |
320 | } | 341 | } |
321 | 342 | ||
@@ -371,8 +392,12 @@ connection_client_destroy_impl (struct GNUNET_MQ_Handle *mq, | |||
371 | GNUNET_SCHEDULER_cancel (cstate->recv_task); | 392 | GNUNET_SCHEDULER_cancel (cstate->recv_task); |
372 | if (NULL != cstate->retry_task) | 393 | if (NULL != cstate->retry_task) |
373 | GNUNET_SCHEDULER_cancel (cstate->retry_task); | 394 | GNUNET_SCHEDULER_cancel (cstate->retry_task); |
374 | if (NULL != cstate->sock) | 395 | if (NULL != cstate->sock){ |
396 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
397 | "client: destroying socket: %p\n", | ||
398 | cstate->sock); | ||
375 | GNUNET_NETWORK_socket_close (cstate->sock); | 399 | GNUNET_NETWORK_socket_close (cstate->sock); |
400 | } | ||
376 | cancel_aps (cstate); | 401 | cancel_aps (cstate); |
377 | GNUNET_free (cstate->service_name); | 402 | GNUNET_free (cstate->service_name); |
378 | GNUNET_free_non_null (cstate->hostname); | 403 | GNUNET_free_non_null (cstate->hostname); |
@@ -794,8 +819,12 @@ connection_client_send_impl (struct GNUNET_MQ_Handle *mq, | |||
794 | GNUNET_assert (NULL == cstate->send_task); | 819 | GNUNET_assert (NULL == cstate->send_task); |
795 | cstate->msg = msg; | 820 | cstate->msg = msg; |
796 | cstate->msg_off = 0; | 821 | cstate->msg_off = 0; |
797 | if (NULL == cstate->sock) | 822 | if (NULL == cstate->sock){ |
823 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
824 | "client: message of type %u waiting for socket\n", | ||
825 | ntohs(msg->type)); | ||
798 | return; /* still waiting for connection */ | 826 | return; /* still waiting for connection */ |
827 | } | ||
799 | cstate->send_task | 828 | cstate->send_task |
800 | = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, | 829 | = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, |
801 | cstate->sock, | 830 | cstate->sock, |
diff --git a/src/util/mq.c b/src/util/mq.c index 90b2aa968..8d71359ac 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -357,6 +357,12 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, | |||
357 | } | 357 | } |
358 | GNUNET_assert (NULL == mq->envelope_head); | 358 | GNUNET_assert (NULL == mq->envelope_head); |
359 | mq->current_envelope = ev; | 359 | mq->current_envelope = ev; |
360 | |||
361 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
362 | "mq: sending message of type %u, queue empty (MQ: %p)\n", | ||
363 | ntohs(ev->mh->type), | ||
364 | mq); | ||
365 | |||
360 | mq->send_impl (mq, | 366 | mq->send_impl (mq, |
361 | ev->mh, | 367 | ev->mh, |
362 | mq->impl_state); | 368 | mq->impl_state); |
@@ -452,6 +458,11 @@ impl_send_continue (void *cls) | |||
452 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, | 458 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, |
453 | mq->envelope_tail, | 459 | mq->envelope_tail, |
454 | mq->current_envelope); | 460 | mq->current_envelope); |
461 | |||
462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
463 | "mq: sending message of type %u from queue\n", | ||
464 | ntohs(mq->current_envelope->mh->type)); | ||
465 | |||
455 | mq->send_impl (mq, | 466 | mq->send_impl (mq, |
456 | mq->current_envelope->mh, | 467 | mq->current_envelope->mh, |
457 | mq->impl_state); | 468 | mq->impl_state); |
@@ -840,6 +851,9 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) | |||
840 | ev); | 851 | ev); |
841 | GNUNET_assert (0 < mq->queue_length); | 852 | GNUNET_assert (0 < mq->queue_length); |
842 | mq->queue_length--; | 853 | mq->queue_length--; |
854 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
855 | "MQ destroy drops message of type %u\n", | ||
856 | ntohs (ev->mh->type)); | ||
843 | GNUNET_MQ_discard (ev); | 857 | GNUNET_MQ_discard (ev); |
844 | } | 858 | } |
845 | if (NULL != mq->current_envelope) | 859 | if (NULL != mq->current_envelope) |
@@ -847,6 +861,9 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) | |||
847 | /* we can only discard envelopes that | 861 | /* we can only discard envelopes that |
848 | * are not queued! */ | 862 | * are not queued! */ |
849 | mq->current_envelope->parent_queue = NULL; | 863 | mq->current_envelope->parent_queue = NULL; |
864 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
865 | "MQ destroy drops current message of type %u\n", | ||
866 | ntohs (mq->current_envelope->mh->type)); | ||
850 | GNUNET_MQ_discard (mq->current_envelope); | 867 | GNUNET_MQ_discard (mq->current_envelope); |
851 | mq->current_envelope = NULL; | 868 | mq->current_envelope = NULL; |
852 | GNUNET_assert (0 < mq->queue_length); | 869 | GNUNET_assert (0 < mq->queue_length); |
@@ -928,6 +945,11 @@ GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev) | |||
928 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, | 945 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, |
929 | mq->envelope_tail, | 946 | mq->envelope_tail, |
930 | mq->current_envelope); | 947 | mq->current_envelope); |
948 | |||
949 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
950 | "mq: sending canceled message of type %u queue\n", | ||
951 | ntohs(ev->mh->type)); | ||
952 | |||
931 | mq->send_impl (mq, | 953 | mq->send_impl (mq, |
932 | mq->current_envelope->mh, | 954 | mq->current_envelope->mh, |
933 | mq->impl_state); | 955 | mq->impl_state); |
diff --git a/src/util/mst.c b/src/util/mst.c index 0d90c5d10..5e472965f 100644 --- a/src/util/mst.c +++ b/src/util/mst.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010, 2016 GNUnet e.V. | 3 | Copyright (C) 2010, 2016, 2017 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -126,6 +126,7 @@ GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst, | |||
126 | int need_align; | 126 | int need_align; |
127 | unsigned long offset; | 127 | unsigned long offset; |
128 | int ret; | 128 | int ret; |
129 | int cbret; | ||
129 | 130 | ||
130 | GNUNET_assert (mst->off <= mst->pos); | 131 | GNUNET_assert (mst->off <= mst->pos); |
131 | GNUNET_assert (mst->pos <= mst->curr_buf); | 132 | GNUNET_assert (mst->pos <= mst->curr_buf); |
@@ -229,9 +230,17 @@ do_align: | |||
229 | if (one_shot == GNUNET_YES) | 230 | if (one_shot == GNUNET_YES) |
230 | one_shot = GNUNET_SYSERR; | 231 | one_shot = GNUNET_SYSERR; |
231 | mst->off += want; | 232 | mst->off += want; |
232 | if (GNUNET_SYSERR == mst->cb (mst->cb_cls, | 233 | if (GNUNET_OK != |
233 | hdr)) | 234 | (cbret = mst->cb (mst->cb_cls, |
235 | hdr))) | ||
236 | { | ||
237 | if (GNUNET_SYSERR == cbret) | ||
238 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
239 | "Failure processing message of type %u and size %u\n", | ||
240 | ntohs (hdr->type), | ||
241 | ntohs (hdr->size)); | ||
234 | return GNUNET_SYSERR; | 242 | return GNUNET_SYSERR; |
243 | } | ||
235 | if (mst->off == mst->pos) | 244 | if (mst->off == mst->pos) |
236 | { | 245 | { |
237 | /* reset to beginning of buffer, it's free right now! */ | 246 | /* reset to beginning of buffer, it's free right now! */ |
@@ -271,9 +280,17 @@ do_align: | |||
271 | } | 280 | } |
272 | if (one_shot == GNUNET_YES) | 281 | if (one_shot == GNUNET_YES) |
273 | one_shot = GNUNET_SYSERR; | 282 | one_shot = GNUNET_SYSERR; |
274 | if (GNUNET_SYSERR == mst->cb (mst->cb_cls, | 283 | if (GNUNET_OK != |
275 | hdr)) | 284 | (cbret = mst->cb (mst->cb_cls, |
285 | hdr))) | ||
286 | { | ||
287 | if (GNUNET_SYSERR == cbret) | ||
288 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
289 | "Failure processing message of type %u and size %u\n", | ||
290 | ntohs (hdr->type), | ||
291 | ntohs (hdr->size)); | ||
276 | return GNUNET_SYSERR; | 292 | return GNUNET_SYSERR; |
293 | } | ||
277 | buf += want; | 294 | buf += want; |
278 | size -= want; | 295 | size -= want; |
279 | } | 296 | } |
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 540a60557..4615ecee9 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -589,9 +589,7 @@ static void | |||
589 | dump_backtrace (struct GNUNET_SCHEDULER_Task *t) | 589 | dump_backtrace (struct GNUNET_SCHEDULER_Task *t) |
590 | { | 590 | { |
591 | #if EXECINFO | 591 | #if EXECINFO |
592 | unsigned int i; | 592 | for (unsigned int i = 0; i < t->num_backtrace_strings; i++) |
593 | |||
594 | for (i = 0; i < t->num_backtrace_strings; i++) | ||
595 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 593 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
596 | "Task %p trace %u: %s\n", | 594 | "Task %p trace %u: %s\n", |
597 | t, | 595 | t, |
diff --git a/src/util/service.c b/src/util/service.c index fcdf45a51..b4eb33caa 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -1932,6 +1932,11 @@ do_send (void *cls) | |||
1932 | size_t left; | 1932 | size_t left; |
1933 | const char *buf; | 1933 | const char *buf; |
1934 | 1934 | ||
1935 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1936 | "service: sending message with type %u", | ||
1937 | ntohs(client->msg->type)); | ||
1938 | |||
1939 | |||
1935 | client->send_task = NULL; | 1940 | client->send_task = NULL; |
1936 | buf = (const char *) client->msg; | 1941 | buf = (const char *) client->msg; |
1937 | left = ntohs (client->msg->size) - client->msg_pos; | 1942 | left = ntohs (client->msg->size) - client->msg_pos; |
@@ -1941,6 +1946,8 @@ do_send (void *cls) | |||
1941 | GNUNET_assert (ret <= (ssize_t) left); | 1946 | GNUNET_assert (ret <= (ssize_t) left); |
1942 | if (0 == ret) | 1947 | if (0 == ret) |
1943 | { | 1948 | { |
1949 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1950 | "no data send"); | ||
1944 | GNUNET_MQ_inject_error (client->mq, | 1951 | GNUNET_MQ_inject_error (client->mq, |
1945 | GNUNET_MQ_ERROR_WRITE); | 1952 | GNUNET_MQ_ERROR_WRITE); |
1946 | return; | 1953 | return; |
@@ -1958,6 +1965,9 @@ do_send (void *cls) | |||
1958 | if (EPIPE != errno) | 1965 | if (EPIPE != errno) |
1959 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, | 1966 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, |
1960 | "send"); | 1967 | "send"); |
1968 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1969 | "socket send returned with error code %i", | ||
1970 | errno); | ||
1961 | GNUNET_MQ_inject_error (client->mq, | 1971 | GNUNET_MQ_inject_error (client->mq, |
1962 | GNUNET_MQ_ERROR_WRITE); | 1972 | GNUNET_MQ_ERROR_WRITE); |
1963 | return; | 1973 | return; |
@@ -2402,7 +2412,7 @@ resume_client_receive (void *cls) | |||
2402 | GNUNET_YES); | 2412 | GNUNET_YES); |
2403 | if (GNUNET_SYSERR == ret) | 2413 | if (GNUNET_SYSERR == ret) |
2404 | { | 2414 | { |
2405 | if (NULL != c->drop_task) | 2415 | if (NULL == c->drop_task) |
2406 | GNUNET_SERVICE_client_drop (c); | 2416 | GNUNET_SERVICE_client_drop (c); |
2407 | return; | 2417 | return; |
2408 | } | 2418 | } |
@@ -2431,6 +2441,7 @@ resume_client_receive (void *cls) | |||
2431 | void | 2441 | void |
2432 | GNUNET_SERVICE_client_continue (struct GNUNET_SERVICE_Client *c) | 2442 | GNUNET_SERVICE_client_continue (struct GNUNET_SERVICE_Client *c) |
2433 | { | 2443 | { |
2444 | GNUNET_assert (NULL == c->drop_task); | ||
2434 | GNUNET_assert (GNUNET_YES == c->needs_continue); | 2445 | GNUNET_assert (GNUNET_YES == c->needs_continue); |
2435 | GNUNET_assert (NULL == c->recv_task); | 2446 | GNUNET_assert (NULL == c->recv_task); |
2436 | c->needs_continue = GNUNET_NO; | 2447 | c->needs_continue = GNUNET_NO; |
@@ -2513,6 +2524,24 @@ GNUNET_SERVICE_client_drop (struct GNUNET_SERVICE_Client *c) | |||
2513 | { | 2524 | { |
2514 | struct GNUNET_SERVICE_Handle *sh = c->sh; | 2525 | struct GNUNET_SERVICE_Handle *sh = c->sh; |
2515 | 2526 | ||
2527 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2528 | "Client dropped: %p (MQ: %p)\n", | ||
2529 | c, | ||
2530 | c->mq); | ||
2531 | |||
2532 | #if EXECINFO | ||
2533 | void *backtrace_array[MAX_TRACE_DEPTH]; | ||
2534 | int num_backtrace_strings = backtrace (backtrace_array, MAX_TRACE_DEPTH); | ||
2535 | char **backtrace_strings = | ||
2536 | backtrace_symbols (backtrace_array, | ||
2537 | t->num_backtrace_strings); | ||
2538 | for (unsigned int i = 0; i < num_backtrace_strings; i++) | ||
2539 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2540 | "client drop trace %u: %s\n", | ||
2541 | i, | ||
2542 | backtrace_strings[i]); | ||
2543 | #endif | ||
2544 | |||
2516 | if (NULL != c->drop_task) | 2545 | if (NULL != c->drop_task) |
2517 | { | 2546 | { |
2518 | /* asked to drop twice! */ | 2547 | /* asked to drop twice! */ |