aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-10-05 16:35:44 +0000
committerChristian Grothoff <christian@grothoff.org>2015-10-05 16:35:44 +0000
commit4dcb414e2faabc800577c25dec3b63e3ceaaa84b (patch)
treec9e7b5139a3f04bbcd65ddfc10d1bab05e6e0741 /src/core
parentef76e090bf279f25038c03eec4eac96bbfbe952e (diff)
downloadgnunet-4dcb414e2faabc800577c25dec3b63e3ceaaa84b.tar.gz
gnunet-4dcb414e2faabc800577c25dec3b63e3ceaaa84b.zip
adding DEBUG logic for #3863
Diffstat (limited to 'src/core')
-rw-r--r--src/core/gnunet-service-core.h5
-rw-r--r--src/core/gnunet-service-core_clients.c94
-rw-r--r--src/core/gnunet-service-core_neighbours.c36
-rw-r--r--src/core/gnunet-service-core_sessions.c4
4 files changed, 107 insertions, 32 deletions
diff --git a/src/core/gnunet-service-core.h b/src/core/gnunet-service-core.h
index a95dc561f..15e995921 100644
--- a/src/core/gnunet-service-core.h
+++ b/src/core/gnunet-service-core.h
@@ -67,6 +67,11 @@ struct GSC_ClientActiveRequest
67 struct GNUNET_PeerIdentity target; 67 struct GNUNET_PeerIdentity target;
68 68
69 /** 69 /**
70 * At what time did we first see this request?
71 */
72 struct GNUNET_TIME_Absolute received_time;
73
74 /**
70 * By what time would the client want to see this message out? 75 * By what time would the client want to see this message out?
71 */ 76 */
72 struct GNUNET_TIME_Absolute deadline; 77 struct GNUNET_TIME_Absolute deadline;
diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c
index e90d91529..57a5d5826 100644
--- a/src/core/gnunet-service-core_clients.c
+++ b/src/core/gnunet-service-core_clients.c
@@ -29,6 +29,7 @@
29#include "gnunet_transport_service.h" 29#include "gnunet_transport_service.h"
30#include "gnunet-service-core.h" 30#include "gnunet-service-core.h"
31#include "gnunet-service-core_clients.h" 31#include "gnunet-service-core_clients.h"
32#include "gnunet-service-core_neighbours.h"
32#include "gnunet-service-core_sessions.h" 33#include "gnunet-service-core_sessions.h"
33#include "gnunet-service-core_typemap.h" 34#include "gnunet-service-core_typemap.h"
34#include "core.h" 35#include "core.h"
@@ -149,7 +150,8 @@ find_client (struct GNUNET_SERVER_Client *client)
149 */ 150 */
150static void 151static void
151send_to_client (struct GSC_Client *client, 152send_to_client (struct GSC_Client *client,
152 const struct GNUNET_MessageHeader *msg, int can_drop) 153 const struct GNUNET_MessageHeader *msg,
154 int can_drop)
153{ 155{
154 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
155 "Preparing to send %u bytes of message of type %u to client.\n", 157 "Preparing to send %u bytes of message of type %u to client.\n",
@@ -219,8 +221,10 @@ type_match (uint16_t type, struct GSC_Client *c)
219 */ 221 */
220static void 222static void
221send_to_all_clients (const struct GNUNET_PeerIdentity *partner, 223send_to_all_clients (const struct GNUNET_PeerIdentity *partner,
222 const struct GNUNET_MessageHeader *msg, int can_drop, 224 const struct GNUNET_MessageHeader *msg,
223 uint32_t options, uint16_t type) 225 int can_drop,
226 uint32_t options,
227 uint16_t type)
224{ 228{
225 struct GSC_Client *c; 229 struct GSC_Client *c;
226 int tm; 230 int tm;
@@ -399,6 +403,7 @@ handle_client_send_request (void *cls,
399 GSC_SESSIONS_dequeue_request (car); 403 GSC_SESSIONS_dequeue_request (car);
400 } 404 }
401 car->target = req->peer; 405 car->target = req->peer;
406 car->received_time = GNUNET_TIME_absolute_get ();
402 car->deadline = GNUNET_TIME_absolute_ntoh (req->deadline); 407 car->deadline = GNUNET_TIME_absolute_ntoh (req->deadline);
403 car->priority = (enum GNUNET_CORE_Priority) ntohl (req->priority); 408 car->priority = (enum GNUNET_CORE_Priority) ntohl (req->priority);
404 car->msize = ntohs (req->size); 409 car->msize = ntohs (req->size);
@@ -441,7 +446,7 @@ struct TokenizerContext
441 446
442 447
443/** 448/**
444 * Handle CORE_SEND request. 449 * Handle #GNUNET_MESSAGE_TYPE_CORE_CORE_SEND request.
445 * 450 *
446 * @param cls unused 451 * @param cls unused
447 * @param client the client issuing the request 452 * @param client the client issuing the request
@@ -456,6 +461,7 @@ handle_client_send (void *cls,
456 struct GSC_Client *c; 461 struct GSC_Client *c;
457 struct TokenizerContext tc; 462 struct TokenizerContext tc;
458 uint16_t msize; 463 uint16_t msize;
464 struct GNUNET_TIME_Relative delay;
459 465
460 msize = ntohs (message->size); 466 msize = ntohs (message->size);
461 if (msize < 467 if (msize <
@@ -476,8 +482,9 @@ handle_client_send (void *cls,
476 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 482 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
477 return; 483 return;
478 } 484 }
479 tc.car = 485 tc.car
480 GNUNET_CONTAINER_multipeermap_get (c->requests, &sm->peer); 486 = GNUNET_CONTAINER_multipeermap_get (c->requests,
487 &sm->peer);
481 if (NULL == tc.car) 488 if (NULL == tc.car)
482 { 489 {
483 /* Must have been that we first approved the request, then got disconnected 490 /* Must have been that we first approved the request, then got disconnected
@@ -489,28 +496,49 @@ handle_client_send (void *cls,
489 gettext_noop 496 gettext_noop
490 ("# messages discarded (session disconnected)"), 497 ("# messages discarded (session disconnected)"),
491 1, GNUNET_NO); 498 1, GNUNET_NO);
492 GNUNET_SERVER_receive_done (client, GNUNET_OK); 499 GNUNET_SERVER_receive_done (client,
500 GNUNET_OK);
493 return; 501 return;
494 } 502 }
503 delay = GNUNET_TIME_absolute_get_duration (tc.car->received_time);
504 tc.cork = ntohl (sm->cork);
505 tc.priority = (enum GNUNET_CORE_Priority) ntohl (sm->priority);
506 if (delay.rel_value_us > GNUNET_TIME_UNIT_SECONDS.rel_value_us)
507 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
508 "Client waited %s for transmission of %u bytes to `%s'%s, CORE queue is %u entries\n",
509 GNUNET_STRINGS_relative_time_to_string (delay,
510 GNUNET_YES),
511 msize,
512 GNUNET_i2s (&sm->peer),
513 tc.cork ? "" : " (corked)",
514 GSC_NEIGHBOURS_get_queue_size (&sm->peer));
515 else
516 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
517 "Client waited %s for transmission of %u bytes to `%s'%s, CORE queue is %u entries\n",
518 GNUNET_STRINGS_relative_time_to_string (delay,
519 GNUNET_YES),
520 msize,
521 GNUNET_i2s (&sm->peer),
522 tc.cork ? "" : " (corked)",
523 GSC_NEIGHBOURS_get_queue_size (&sm->peer));
524
495 GNUNET_assert (GNUNET_YES == 525 GNUNET_assert (GNUNET_YES ==
496 GNUNET_CONTAINER_multipeermap_remove (c->requests, 526 GNUNET_CONTAINER_multipeermap_remove (c->requests,
497 &sm->peer, 527 &sm->peer,
498 tc.car)); 528 tc.car));
499 tc.cork = ntohl (sm->cork);
500 tc.priority = (enum GNUNET_CORE_Priority) ntohl (sm->priority);
501 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
502 "Client asked for transmission of %u bytes to `%s' %s\n",
503 msize,
504 GNUNET_i2s (&sm->peer), tc.cork ? "now" : "");
505 GNUNET_SERVER_mst_receive (client_mst, &tc, 529 GNUNET_SERVER_mst_receive (client_mst, &tc,
506 (const char *) &sm[1], msize, 530 (const char *) &sm[1],
507 GNUNET_YES, GNUNET_NO); 531 msize,
532 GNUNET_YES,
533 GNUNET_NO);
508 if (0 != 534 if (0 !=
509 memcmp (&tc.car->target, &GSC_my_identity, 535 memcmp (&tc.car->target,
536 &GSC_my_identity,
510 sizeof (struct GNUNET_PeerIdentity))) 537 sizeof (struct GNUNET_PeerIdentity)))
511 GSC_SESSIONS_dequeue_request (tc.car); 538 GSC_SESSIONS_dequeue_request (tc.car);
512 GNUNET_free (tc.car); 539 GNUNET_free (tc.car);
513 GNUNET_SERVER_receive_done (client, GNUNET_OK); 540 GNUNET_SERVER_receive_done (client,
541 GNUNET_OK);
514} 542}
515 543
516 544
@@ -525,7 +553,8 @@ handle_client_send (void *cls,
525 * @param message the actual message 553 * @param message the actual message
526 */ 554 */
527static int 555static int
528client_tokenizer_callback (void *cls, void *client, 556client_tokenizer_callback (void *cls,
557 void *client,
529 const struct GNUNET_MessageHeader *message) 558 const struct GNUNET_MessageHeader *message)
530{ 559{
531 struct TokenizerContext *tc = client; 560 struct TokenizerContext *tc = client;
@@ -535,9 +564,13 @@ client_tokenizer_callback (void *cls, void *client,
535 GNUNET_snprintf (buf, sizeof (buf), 564 GNUNET_snprintf (buf, sizeof (buf),
536 gettext_noop ("# bytes of messages of type %u received"), 565 gettext_noop ("# bytes of messages of type %u received"),
537 (unsigned int) ntohs (message->type)); 566 (unsigned int) ntohs (message->type));
538 GNUNET_STATISTICS_update (GSC_stats, buf, ntohs (message->size), GNUNET_NO); 567 GNUNET_STATISTICS_update (GSC_stats,
568 buf,
569 ntohs (message->size),
570 GNUNET_NO);
539 if (0 == 571 if (0 ==
540 memcmp (&car->target, &GSC_my_identity, 572 memcmp (&car->target,
573 &GSC_my_identity,
541 sizeof (struct GNUNET_PeerIdentity))) 574 sizeof (struct GNUNET_PeerIdentity)))
542 { 575 {
543 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 576 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -618,7 +651,8 @@ handle_client_disconnect (void *cls,
618 if (NULL == client) 651 if (NULL == client)
619 return; 652 return;
620 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 653 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
621 "Client %p has disconnected from core service.\n", client); 654 "Client %p has disconnected from core service.\n",
655 client);
622 c = find_client (client); 656 c = find_client (client);
623 if (c == NULL) 657 if (c == NULL)
624 return; /* client never sent INIT */ 658 return; /* client never sent INIT */
@@ -654,6 +688,8 @@ GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car)
654{ 688{
655 struct GSC_Client *c; 689 struct GSC_Client *c;
656 struct SendMessageReady smr; 690 struct SendMessageReady smr;
691 struct GNUNET_TIME_Relative delay;
692 struct GNUNET_TIME_Relative left;
657 693
658 c = car->client_handle; 694 c = car->client_handle;
659 if (GNUNET_YES != 695 if (GNUNET_YES !=
@@ -662,12 +698,26 @@ GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car)
662 { 698 {
663 /* connection has gone down since, drop request */ 699 /* connection has gone down since, drop request */
664 GNUNET_assert (0 != 700 GNUNET_assert (0 !=
665 memcmp (&car->target, &GSC_my_identity, 701 memcmp (&car->target,
702 &GSC_my_identity,
666 sizeof (struct GNUNET_PeerIdentity))); 703 sizeof (struct GNUNET_PeerIdentity)));
667 GSC_SESSIONS_dequeue_request (car); 704 GSC_SESSIONS_dequeue_request (car);
668 GSC_CLIENTS_reject_request (car); 705 GSC_CLIENTS_reject_request (car);
669 return; 706 return;
670 } 707 }
708 delay = GNUNET_TIME_absolute_get_duration (car->received_time);
709 left = GNUNET_TIME_absolute_get_remaining (car->deadline);
710 if ( (delay.rel_value_us > GNUNET_TIME_UNIT_SECONDS.rel_value_us) ||
711 (0 == left.rel_value_us) )
712 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
713 "Client waited %s for permission to transmit to `%s'%s (priority %u)\n",
714 GNUNET_STRINGS_relative_time_to_string (delay,
715 GNUNET_YES),
716 GNUNET_i2s (&car->target),
717 (0 == left.rel_value_us)
718 ? " (past deadline)"
719 : "",
720 car->priority);
671 smr.header.size = htons (sizeof (struct SendMessageReady)); 721 smr.header.size = htons (sizeof (struct SendMessageReady));
672 smr.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND_READY); 722 smr.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND_READY);
673 smr.size = htons (car->msize); 723 smr.size = htons (car->msize);
diff --git a/src/core/gnunet-service-core_neighbours.c b/src/core/gnunet-service-core_neighbours.c
index 5e5ed4db3..f89206dfe 100644
--- a/src/core/gnunet-service-core_neighbours.c
+++ b/src/core/gnunet-service-core_neighbours.c
@@ -57,9 +57,14 @@ struct NeighbourMessageEntry
57 struct GNUNET_TIME_Absolute deadline; 57 struct GNUNET_TIME_Absolute deadline;
58 58
59 /** 59 /**
60 * How long is the message? (number of bytes following the "struct 60 * What time did we submit the request?
61 * MessageEntry", but not including the size of "struct 61 */
62 * MessageEntry" itself!) 62 struct GNUNET_TIME_Absolute submission_time;
63
64 /**
65 * How long is the message? (number of bytes following the `struct
66 * MessageEntry`, but not including the size of `struct
67 * MessageEntry` itself!)
63 */ 68 */
64 size_t size; 69 size_t size;
65 70
@@ -157,7 +162,7 @@ free_neighbour (struct Neighbour *n)
157 struct NeighbourMessageEntry *m; 162 struct NeighbourMessageEntry *m;
158 163
159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 164 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
160 "Destroying neighbour entry for peer `%4s'\n", 165 "Destroying neighbour entry for peer `%s'\n",
161 GNUNET_i2s (&n->peer)); 166 GNUNET_i2s (&n->peer));
162 while (NULL != (m = n->message_head)) 167 while (NULL != (m = n->message_head))
163 { 168 {
@@ -227,6 +232,7 @@ transmit_ready (void *cls,
227 struct NeighbourMessageEntry *m; 232 struct NeighbourMessageEntry *m;
228 size_t ret; 233 size_t ret;
229 char *cbuf; 234 char *cbuf;
235 struct GNUNET_TIME_Relative delay;
230 236
231 n->th = NULL; 237 n->th = NULL;
232 m = n->message_head; 238 m = n->message_head;
@@ -250,18 +256,31 @@ transmit_ready (void *cls,
250 process_queue (n); 256 process_queue (n);
251 return 0; 257 return 0;
252 } 258 }
259 delay = GNUNET_TIME_absolute_get_duration (m->submission_time);
253 cbuf = buf; 260 cbuf = buf;
254 GNUNET_assert (size >= m->size); 261 GNUNET_assert (size >= m->size);
255 memcpy (cbuf, 262 memcpy (cbuf,
256 &m[1], 263 &m[1],
257 m->size); 264 m->size);
258 ret = m->size; 265 ret = m->size;
259 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 266 if (delay.rel_value_us > GNUNET_TIME_UNIT_SECONDS.rel_value_us)
260 "Copied message of type %u and size %u into transport buffer for `%4s'\n", 267 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
268 "Copied message of type %u and size %u into transport buffer for `%s' with delay of %s\n",
261 (unsigned int) 269 (unsigned int)
262 ntohs (((struct GNUNET_MessageHeader *) &m[1])->type), 270 ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
263 (unsigned int) ret, 271 (unsigned int) ret,
264 GNUNET_i2s (&n->peer)); 272 GNUNET_i2s (&n->peer),
273 GNUNET_STRINGS_relative_time_to_string (delay,
274 GNUNET_YES));
275 else
276 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
277 "Copied message of type %u and size %u into transport buffer for `%s' with delay of %s\n",
278 (unsigned int)
279 ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
280 (unsigned int) ret,
281 GNUNET_i2s (&n->peer),
282 GNUNET_STRINGS_relative_time_to_string (delay,
283 GNUNET_YES));
265 GNUNET_free (m); 284 GNUNET_free (m);
266 n->has_excess_bandwidth = GNUNET_NO; 285 n->has_excess_bandwidth = GNUNET_NO;
267 process_queue (n); 286 process_queue (n);
@@ -295,11 +314,12 @@ process_queue (struct Neighbour *n)
295 return; 314 return;
296 } 315 }
297 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 316 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
298 "Asking transport for transmission of %u bytes to `%4s' in next %s\n", 317 "Asking transport for transmission of %u bytes to `%s' in next %s\n",
299 (unsigned int) m->size, 318 (unsigned int) m->size,
300 GNUNET_i2s (&n->peer), 319 GNUNET_i2s (&n->peer),
301 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (m->deadline), 320 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (m->deadline),
302 GNUNET_NO)); 321 GNUNET_NO));
322 m->submission_time = GNUNET_TIME_absolute_get ();
303 n->th 323 n->th
304 = GNUNET_TRANSPORT_notify_transmit_ready (transport, 324 = GNUNET_TRANSPORT_notify_transmit_ready (transport,
305 &n->peer, 325 &n->peer,
diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c
index 8706c873e..bbabf8866 100644
--- a/src/core/gnunet-service-core_sessions.c
+++ b/src/core/gnunet-service-core_sessions.c
@@ -125,12 +125,12 @@ struct Session
125 /** 125 /**
126 * Task to transmit corked messages with a delay. 126 * Task to transmit corked messages with a delay.
127 */ 127 */
128 struct GNUNET_SCHEDULER_Task * cork_task; 128 struct GNUNET_SCHEDULER_Task *cork_task;
129 129
130 /** 130 /**
131 * Task to transmit our type map. 131 * Task to transmit our type map.
132 */ 132 */
133 struct GNUNET_SCHEDULER_Task * typemap_task; 133 struct GNUNET_SCHEDULER_Task *typemap_task;
134 134
135 /** 135 /**
136 * Retransmission delay we currently use for the typemap 136 * Retransmission delay we currently use for the typemap