diff options
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/client.c | 27 | ||||
-rw-r--r-- | src/util/mq.c | 54 | ||||
-rw-r--r-- | src/util/service.c | 48 |
3 files changed, 122 insertions, 7 deletions
diff --git a/src/util/client.c b/src/util/client.c index 8012c1523..e5bf7e176 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -261,6 +261,12 @@ 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], |
@@ -268,10 +274,12 @@ transmit_ready (void *cls) | |||
268 | if (-1 == ret) | 274 | if (-1 == ret) |
269 | { | 275 | { |
270 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 276 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
271 | "client: error during sending message of type %u\n", ntohs(cstate->msg->type)); | 277 | "client: error during sending message of type %u\n", |
278 | ntohs(cstate->msg->type)); | ||
272 | if (EINTR == errno){ | 279 | if (EINTR == errno){ |
273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
274 | "client: retrying message of type %u\n", ntohs(cstate->msg->type)); | 281 | "client: retrying message of type %u\n", |
282 | ntohs(cstate->msg->type)); | ||
275 | goto RETRY; | 283 | goto RETRY; |
276 | } | 284 | } |
277 | GNUNET_MQ_inject_error (cstate->mq, | 285 | GNUNET_MQ_inject_error (cstate->mq, |
@@ -283,7 +291,8 @@ transmit_ready (void *cls) | |||
283 | if (cstate->msg_off < len) | 291 | if (cstate->msg_off < len) |
284 | { | 292 | { |
285 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 293 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
286 | "client: rescheduling message of type %u\n", ntohs(cstate->msg->type)); | 294 | "client: rescheduling message of type %u\n", |
295 | ntohs(cstate->msg->type)); | ||
287 | cstate->send_task | 296 | cstate->send_task |
288 | = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, | 297 | = GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, |
289 | cstate->sock, | 298 | cstate->sock, |
@@ -294,7 +303,8 @@ transmit_ready (void *cls) | |||
294 | return; | 303 | return; |
295 | } | 304 | } |
296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
297 | "client: sending message of type %u successful\n", ntohs(cstate->msg->type)); | 306 | "client: sending message of type %u successful\n", |
307 | ntohs(cstate->msg->type)); | ||
298 | cstate->msg = NULL; | 308 | cstate->msg = NULL; |
299 | GNUNET_MQ_impl_send_continue (cstate->mq); | 309 | GNUNET_MQ_impl_send_continue (cstate->mq); |
300 | } | 310 | } |
@@ -382,8 +392,12 @@ connection_client_destroy_impl (struct GNUNET_MQ_Handle *mq, | |||
382 | GNUNET_SCHEDULER_cancel (cstate->recv_task); | 392 | GNUNET_SCHEDULER_cancel (cstate->recv_task); |
383 | if (NULL != cstate->retry_task) | 393 | if (NULL != cstate->retry_task) |
384 | GNUNET_SCHEDULER_cancel (cstate->retry_task); | 394 | GNUNET_SCHEDULER_cancel (cstate->retry_task); |
385 | 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); | ||
386 | GNUNET_NETWORK_socket_close (cstate->sock); | 399 | GNUNET_NETWORK_socket_close (cstate->sock); |
400 | } | ||
387 | cancel_aps (cstate); | 401 | cancel_aps (cstate); |
388 | GNUNET_free (cstate->service_name); | 402 | GNUNET_free (cstate->service_name); |
389 | GNUNET_free_non_null (cstate->hostname); | 403 | GNUNET_free_non_null (cstate->hostname); |
@@ -807,7 +821,8 @@ connection_client_send_impl (struct GNUNET_MQ_Handle *mq, | |||
807 | cstate->msg_off = 0; | 821 | cstate->msg_off = 0; |
808 | if (NULL == cstate->sock){ | 822 | if (NULL == cstate->sock){ |
809 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 823 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
810 | "client: waiting for socket\n"); | 824 | "client: message of type %u waiting for socket\n", |
825 | ntohs(msg->type)); | ||
811 | return; /* still waiting for connection */ | 826 | return; /* still waiting for connection */ |
812 | } | 827 | } |
813 | cstate->send_task | 828 | cstate->send_task |
diff --git a/src/util/mq.c b/src/util/mq.c index 57d2d05c5..3c1fba149 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -28,6 +28,30 @@ | |||
28 | 28 | ||
29 | #define LOG(kind,...) GNUNET_log_from (kind, "util-mq",__VA_ARGS__) | 29 | #define LOG(kind,...) GNUNET_log_from (kind, "util-mq",__VA_ARGS__) |
30 | 30 | ||
31 | //#if HAVE_EXECINFO_H | ||
32 | //#include "execinfo.h" | ||
33 | |||
34 | ///** | ||
35 | // * Use lsof to generate file descriptor reports on select error? | ||
36 | // * (turn off for stable releases). | ||
37 | // */ | ||
38 | //#define USE_LSOF GNUNET_NO | ||
39 | |||
40 | ///** | ||
41 | // * Obtain trace information for all scheduler calls that schedule tasks. | ||
42 | // */ | ||
43 | //#define EXECINFO GNUNET_NO | ||
44 | |||
45 | ///** | ||
46 | // * Check each file descriptor before adding | ||
47 | // */ | ||
48 | //#define DEBUG_FDS GNUNET_NO | ||
49 | |||
50 | ///** | ||
51 | // * Depth of the traces collected via EXECINFO. | ||
52 | // */ | ||
53 | //#define MAX_TRACE_DEPTH 50 | ||
54 | //#endif | ||
31 | 55 | ||
32 | struct GNUNET_MQ_Envelope | 56 | struct GNUNET_MQ_Envelope |
33 | { | 57 | { |
@@ -357,6 +381,12 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, | |||
357 | } | 381 | } |
358 | GNUNET_assert (NULL == mq->envelope_head); | 382 | GNUNET_assert (NULL == mq->envelope_head); |
359 | mq->current_envelope = ev; | 383 | mq->current_envelope = ev; |
384 | |||
385 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
386 | "mq: sending message of type %u, queue empty (MQ: %p)\n", | ||
387 | ntohs(ev->mh->type), | ||
388 | mq); | ||
389 | |||
360 | mq->send_impl (mq, | 390 | mq->send_impl (mq, |
361 | ev->mh, | 391 | ev->mh, |
362 | mq->impl_state); | 392 | mq->impl_state); |
@@ -452,6 +482,11 @@ impl_send_continue (void *cls) | |||
452 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, | 482 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, |
453 | mq->envelope_tail, | 483 | mq->envelope_tail, |
454 | mq->current_envelope); | 484 | mq->current_envelope); |
485 | |||
486 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
487 | "mq: sending message of type %u from queue\n", | ||
488 | ntohs(mq->current_envelope->mh->type)); | ||
489 | |||
455 | mq->send_impl (mq, | 490 | mq->send_impl (mq, |
456 | mq->current_envelope->mh, | 491 | mq->current_envelope->mh, |
457 | mq->impl_state); | 492 | mq->impl_state); |
@@ -851,8 +886,20 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq) | |||
851 | * are not queued! */ | 886 | * are not queued! */ |
852 | mq->current_envelope->parent_queue = NULL; | 887 | mq->current_envelope->parent_queue = NULL; |
853 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 888 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
854 | "MQ destroy drops message of type %u\n", | 889 | "MQ destroy drops current message of type %u\n", |
855 | ntohs (mq->current_envelope->mh->type)); | 890 | ntohs (mq->current_envelope->mh->type)); |
891 | //#if EXECINFO | ||
892 | // void *backtrace_array[MAX_TRACE_DEPTH]; | ||
893 | // int num_backtrace_strings = backtrace (backtrace_array, MAX_TRACE_DEPTH); | ||
894 | // char **backtrace_strings = | ||
895 | // backtrace_symbols (backtrace_array, | ||
896 | // t->num_backtrace_strings); | ||
897 | // for (unsigned int i = 0; i < num_backtrace_strings; i++) | ||
898 | // LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
899 | // "client drop trace %u: %s\n", | ||
900 | // i, | ||
901 | // backtrace_strings[i]); | ||
902 | //#endif | ||
856 | GNUNET_MQ_discard (mq->current_envelope); | 903 | GNUNET_MQ_discard (mq->current_envelope); |
857 | mq->current_envelope = NULL; | 904 | mq->current_envelope = NULL; |
858 | GNUNET_assert (0 < mq->queue_length); | 905 | GNUNET_assert (0 < mq->queue_length); |
@@ -934,6 +981,11 @@ GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev) | |||
934 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, | 981 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, |
935 | mq->envelope_tail, | 982 | mq->envelope_tail, |
936 | mq->current_envelope); | 983 | mq->current_envelope); |
984 | |||
985 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
986 | "mq: sending canceled message of type %u queue\n", | ||
987 | ntohs(ev->mh->type)); | ||
988 | |||
937 | mq->send_impl (mq, | 989 | mq->send_impl (mq, |
938 | mq->current_envelope->mh, | 990 | mq->current_envelope->mh, |
939 | mq->impl_state); | 991 | mq->impl_state); |
diff --git a/src/util/service.c b/src/util/service.c index 782adf5c5..c204f1f87 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -36,6 +36,30 @@ | |||
36 | #include "gauger.h" | 36 | #include "gauger.h" |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | //#if HAVE_EXECINFO_H | ||
40 | //#include "execinfo.h" | ||
41 | |||
42 | ///** | ||
43 | // * Use lsof to generate file descriptor reports on select error? | ||
44 | // * (turn off for stable releases). | ||
45 | // */ | ||
46 | //#define USE_LSOF GNUNET_NO | ||
47 | |||
48 | ///** | ||
49 | // * Obtain trace information for all scheduler calls that schedule tasks. | ||
50 | // */ | ||
51 | //#define EXECINFO GNUNET_NO | ||
52 | |||
53 | ///** | ||
54 | // * Check each file descriptor before adding | ||
55 | // */ | ||
56 | //#define DEBUG_FDS GNUNET_NO | ||
57 | |||
58 | ///** | ||
59 | // * Depth of the traces collected via EXECINFO. | ||
60 | // */ | ||
61 | //#define MAX_TRACE_DEPTH 50 | ||
62 | //#endif | ||
39 | 63 | ||
40 | #define LOG(kind,...) GNUNET_log_from (kind, "util-service", __VA_ARGS__) | 64 | #define LOG(kind,...) GNUNET_log_from (kind, "util-service", __VA_ARGS__) |
41 | 65 | ||
@@ -1932,6 +1956,11 @@ do_send (void *cls) | |||
1932 | size_t left; | 1956 | size_t left; |
1933 | const char *buf; | 1957 | const char *buf; |
1934 | 1958 | ||
1959 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1960 | "service: sending message with type %u", | ||
1961 | ntohs(client->msg->type)); | ||
1962 | |||
1963 | |||
1935 | client->send_task = NULL; | 1964 | client->send_task = NULL; |
1936 | buf = (const char *) client->msg; | 1965 | buf = (const char *) client->msg; |
1937 | left = ntohs (client->msg->size) - client->msg_pos; | 1966 | left = ntohs (client->msg->size) - client->msg_pos; |
@@ -1941,6 +1970,8 @@ do_send (void *cls) | |||
1941 | GNUNET_assert (ret <= (ssize_t) left); | 1970 | GNUNET_assert (ret <= (ssize_t) left); |
1942 | if (0 == ret) | 1971 | if (0 == ret) |
1943 | { | 1972 | { |
1973 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1974 | "no data send"); | ||
1944 | GNUNET_MQ_inject_error (client->mq, | 1975 | GNUNET_MQ_inject_error (client->mq, |
1945 | GNUNET_MQ_ERROR_WRITE); | 1976 | GNUNET_MQ_ERROR_WRITE); |
1946 | return; | 1977 | return; |
@@ -1958,6 +1989,9 @@ do_send (void *cls) | |||
1958 | if (EPIPE != errno) | 1989 | if (EPIPE != errno) |
1959 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, | 1990 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, |
1960 | "send"); | 1991 | "send"); |
1992 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1993 | "socket send returned with error code %i", | ||
1994 | errno); | ||
1961 | GNUNET_MQ_inject_error (client->mq, | 1995 | GNUNET_MQ_inject_error (client->mq, |
1962 | GNUNET_MQ_ERROR_WRITE); | 1996 | GNUNET_MQ_ERROR_WRITE); |
1963 | return; | 1997 | return; |
@@ -2518,6 +2552,20 @@ GNUNET_SERVICE_client_drop (struct GNUNET_SERVICE_Client *c) | |||
2518 | "Client dropped: %p (MQ: %p)\n", | 2552 | "Client dropped: %p (MQ: %p)\n", |
2519 | c, | 2553 | c, |
2520 | c->mq); | 2554 | c->mq); |
2555 | |||
2556 | //#if EXECINFO | ||
2557 | // void *backtrace_array[MAX_TRACE_DEPTH]; | ||
2558 | // int num_backtrace_strings = backtrace (backtrace_array, MAX_TRACE_DEPTH); | ||
2559 | // char **backtrace_strings = | ||
2560 | // backtrace_symbols (backtrace_array, | ||
2561 | // t->num_backtrace_strings); | ||
2562 | // for (unsigned int i = 0; i < num_backtrace_strings; i++) | ||
2563 | // LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2564 | // "client drop trace %u: %s\n", | ||
2565 | // i, | ||
2566 | // backtrace_strings[i]); | ||
2567 | //#endif | ||
2568 | |||
2521 | if (NULL != c->drop_task) | 2569 | if (NULL != c->drop_task) |
2522 | { | 2570 | { |
2523 | /* asked to drop twice! */ | 2571 | /* asked to drop twice! */ |