diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-01-02 01:22:04 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-01-02 01:22:04 +0100 |
commit | 18a677a335becdb59d22cc60a04253268ed2ecd6 (patch) | |
tree | 4e474339f8479c389b66a72407bafb76093fa7f8 /src/cadet | |
parent | 04ff2b8f3b3b499e56a878b2d9166f03f7610784 (diff) | |
download | gnunet-18a677a335becdb59d22cc60a04253268ed2ecd6.tar.gz gnunet-18a677a335becdb59d22cc60a04253268ed2ecd6.zip |
fix issue with sending BROKEN timeouts early due to wrong timeout calculation
Diffstat (limited to 'src/cadet')
-rw-r--r-- | src/cadet/cadet_api.c | 6 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_core.c | 9 | ||||
-rw-r--r-- | src/cadet/test_cadet.c | 100 |
3 files changed, 79 insertions, 36 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c index 366e31405..497c9a4f0 100644 --- a/src/cadet/cadet_api.c +++ b/src/cadet/cadet_api.c | |||
@@ -391,6 +391,8 @@ destroy_channel_on_reconnect_cb (void *cls, | |||
391 | /* struct GNUNET_CADET_Handle *handle = cls; */ | 391 | /* struct GNUNET_CADET_Handle *handle = cls; */ |
392 | struct GNUNET_CADET_Channel *ch = value; | 392 | struct GNUNET_CADET_Channel *ch = value; |
393 | 393 | ||
394 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
395 | "Destroying channel due to reconnect\n"); | ||
394 | destroy_channel (ch); | 396 | destroy_channel (ch); |
395 | return GNUNET_OK; | 397 | return GNUNET_OK; |
396 | } | 398 | } |
@@ -1197,6 +1199,8 @@ destroy_channel_cb (void *cls, | |||
1197 | "channel %X not destroyed\n", | 1199 | "channel %X not destroyed\n", |
1198 | ntohl (ch->ccn.channel_of_client)); | 1200 | ntohl (ch->ccn.channel_of_client)); |
1199 | } | 1201 | } |
1202 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1203 | "Destroying channel due to GNUNET_CADET_disconnect()\n"); | ||
1200 | destroy_channel (ch); | 1204 | destroy_channel (ch); |
1201 | return GNUNET_OK; | 1205 | return GNUNET_OK; |
1202 | } | 1206 | } |
@@ -1311,6 +1315,8 @@ GNUNET_CADET_channel_destroy (struct GNUNET_CADET_Channel *channel) | |||
1311 | GNUNET_MQ_send (h->mq, | 1315 | GNUNET_MQ_send (h->mq, |
1312 | env); | 1316 | env); |
1313 | } | 1317 | } |
1318 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1319 | "Destroying channel due to GNUNET_CADET_channel_destroy()\n"); | ||
1314 | destroy_channel (channel); | 1320 | destroy_channel (channel); |
1315 | } | 1321 | } |
1316 | 1322 | ||
diff --git a/src/cadet/gnunet-service-cadet_core.c b/src/cadet/gnunet-service-cadet_core.c index 99957d8a1..84aff1857 100644 --- a/src/cadet/gnunet-service-cadet_core.c +++ b/src/cadet/gnunet-service-cadet_core.c | |||
@@ -623,7 +623,7 @@ timeout_cb (void *cls) | |||
623 | { | 623 | { |
624 | exp = GNUNET_TIME_absolute_add (r->last_use, | 624 | exp = GNUNET_TIME_absolute_add (r->last_use, |
625 | linger); | 625 | linger); |
626 | if (0 != GNUNET_TIME_absolute_get_duration (exp).rel_value_us) | 626 | if (0 != GNUNET_TIME_absolute_get_remaining (exp).rel_value_us) |
627 | { | 627 | { |
628 | /* Route not yet timed out, wait until it does. */ | 628 | /* Route not yet timed out, wait until it does. */ |
629 | timeout_task = GNUNET_SCHEDULER_add_at (exp, | 629 | timeout_task = GNUNET_SCHEDULER_add_at (exp, |
@@ -631,6 +631,11 @@ timeout_cb (void *cls) | |||
631 | NULL); | 631 | NULL); |
632 | return; | 632 | return; |
633 | } | 633 | } |
634 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
635 | "Sending BROKEN due to timeout (%s was last use, %s linger)\n", | ||
636 | GNUNET_STRINGS_absolute_time_to_string (r->last_use), | ||
637 | GNUNET_STRINGS_relative_time_to_string (linger, | ||
638 | GNUNET_YES)); | ||
634 | send_broken (&r->prev, | 639 | send_broken (&r->prev, |
635 | &r->cid, | 640 | &r->cid, |
636 | NULL, | 641 | NULL, |
@@ -688,6 +693,8 @@ dir_ready_cb (void *cls, | |||
688 | return; | 693 | return; |
689 | } | 694 | } |
690 | odir = (dir == &route->next) ? &route->prev : &route->next; | 695 | odir = (dir == &route->next) ? &route->prev : &route->next; |
696 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
697 | "Sending BROKEN due to MQ going down\n"); | ||
691 | send_broken (&route->next, | 698 | send_broken (&route->next, |
692 | &route->cid, | 699 | &route->cid, |
693 | GCP_get_id (odir->hop), | 700 | GCP_get_id (odir->hop), |
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c index bc4414054..5cc9706d7 100644 --- a/src/cadet/test_cadet.c +++ b/src/cadet/test_cadet.c | |||
@@ -274,12 +274,20 @@ show_end_data (void) | |||
274 | 274 | ||
275 | end_time = GNUNET_TIME_absolute_get (); | 275 | end_time = GNUNET_TIME_absolute_get (); |
276 | total_time = GNUNET_TIME_absolute_get_difference (start_time, end_time); | 276 | total_time = GNUNET_TIME_absolute_get_difference (start_time, end_time); |
277 | FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name); | 277 | FPRINTF (stderr, |
278 | FPRINTF (stderr, "Test time %s\n", | 278 | "\nResults of test \"%s\"\n", |
279 | test_name); | ||
280 | FPRINTF (stderr, | ||
281 | "Test time %s\n", | ||
279 | GNUNET_STRINGS_relative_time_to_string (total_time, GNUNET_YES)); | 282 | GNUNET_STRINGS_relative_time_to_string (total_time, GNUNET_YES)); |
280 | FPRINTF (stderr, "Test bandwidth: %f kb/s\n", 4 * total_packets * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms | 283 | FPRINTF (stderr, |
281 | FPRINTF (stderr, "Test throughput: %f packets/s\n\n", total_packets * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms | 284 | "Test bandwidth: %f kb/s\n", |
282 | GAUGER ("CADET", test_name, | 285 | 4 * total_packets * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms |
286 | FPRINTF (stderr, | ||
287 | "Test throughput: %f packets/s\n\n", | ||
288 | total_packets * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms | ||
289 | GAUGER ("CADET", | ||
290 | test_name, | ||
283 | total_packets * 1000.0 / (total_time.rel_value_us / 1000), | 291 | total_packets * 1000.0 / (total_time.rel_value_us / 1000), |
284 | "packets/s"); | 292 | "packets/s"); |
285 | } | 293 | } |
@@ -295,13 +303,12 @@ static void | |||
295 | disconnect_cadet_peers (void *cls) | 303 | disconnect_cadet_peers (void *cls) |
296 | { | 304 | { |
297 | long line = (long) cls; | 305 | long line = (long) cls; |
298 | unsigned int i; | ||
299 | 306 | ||
300 | disconnect_task = NULL; | 307 | disconnect_task = NULL; |
301 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 308 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
302 | "disconnecting cadet service of peers, called from line %ld\n", | 309 | "disconnecting cadet service of peers, called from line %ld\n", |
303 | line); | 310 | line); |
304 | for (i = 0; i < 2; i++) | 311 | for (unsigned int i = 0; i < 2; i++) |
305 | { | 312 | { |
306 | GNUNET_TESTBED_operation_done (t_op[i]); | 313 | GNUNET_TESTBED_operation_done (t_op[i]); |
307 | } | 314 | } |
@@ -329,7 +336,8 @@ disconnect_cadet_peers (void *cls) | |||
329 | static void | 336 | static void |
330 | shutdown_task (void *cls) | 337 | shutdown_task (void *cls) |
331 | { | 338 | { |
332 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n"); | 339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
340 | "Ending test.\n"); | ||
333 | if (NULL != send_next_msg_task) | 341 | if (NULL != send_next_msg_task) |
334 | { | 342 | { |
335 | GNUNET_SCHEDULER_cancel (send_next_msg_task); | 343 | GNUNET_SCHEDULER_cancel (send_next_msg_task); |
@@ -344,7 +352,8 @@ shutdown_task (void *cls) | |||
344 | { | 352 | { |
345 | GNUNET_SCHEDULER_cancel (disconnect_task); | 353 | GNUNET_SCHEDULER_cancel (disconnect_task); |
346 | disconnect_task = | 354 | disconnect_task = |
347 | GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, (void *) __LINE__); | 355 | GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, |
356 | (void *) __LINE__); | ||
348 | } | 357 | } |
349 | } | 358 | } |
350 | 359 | ||
@@ -359,10 +368,14 @@ shutdown_task (void *cls) | |||
359 | * operation has executed successfully. | 368 | * operation has executed successfully. |
360 | */ | 369 | */ |
361 | static void | 370 | static void |
362 | stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | 371 | stats_cont (void *cls, |
372 | struct GNUNET_TESTBED_Operation *op, | ||
373 | const char *emsg) | ||
363 | { | 374 | { |
364 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " KA sent: %u, KA received: %u\n", | 375 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
365 | ka_sent, ka_received); | 376 | "KA sent: %u, KA received: %u\n", |
377 | ka_sent, | ||
378 | ka_received); | ||
366 | if ((KEEPALIVE == test) && ((ka_sent < 2) || (ka_sent > ka_received + 1))) | 379 | if ((KEEPALIVE == test) && ((ka_sent < 2) || (ka_sent > ka_received + 1))) |
367 | { | 380 | { |
368 | GNUNET_break (0); | 381 | GNUNET_break (0); |
@@ -372,7 +385,8 @@ stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg) | |||
372 | 385 | ||
373 | if (NULL != disconnect_task) | 386 | if (NULL != disconnect_task) |
374 | GNUNET_SCHEDULER_cancel (disconnect_task); | 387 | GNUNET_SCHEDULER_cancel (disconnect_task); |
375 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, cls); | 388 | disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, |
389 | cls); | ||
376 | } | 390 | } |
377 | 391 | ||
378 | 392 | ||
@@ -443,7 +457,6 @@ gather_stats_and_exit (void *cls) | |||
443 | } | 457 | } |
444 | 458 | ||
445 | 459 | ||
446 | |||
447 | /** | 460 | /** |
448 | * Abort test: schedule disconnect and shutdown immediately | 461 | * Abort test: schedule disconnect and shutdown immediately |
449 | * | 462 | * |
@@ -455,9 +468,12 @@ abort_test (long line) | |||
455 | if (NULL != disconnect_task) | 468 | if (NULL != disconnect_task) |
456 | { | 469 | { |
457 | GNUNET_SCHEDULER_cancel (disconnect_task); | 470 | GNUNET_SCHEDULER_cancel (disconnect_task); |
458 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting test from %ld\n", line); | 471 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
472 | "Aborting test from %ld\n", | ||
473 | line); | ||
459 | disconnect_task = | 474 | disconnect_task = |
460 | GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, (void *) line); | 475 | GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, |
476 | (void *) line); | ||
461 | } | 477 | } |
462 | } | 478 | } |
463 | 479 | ||
@@ -579,7 +595,7 @@ reschedule_timeout_task (long line) | |||
579 | if (NULL != disconnect_task) | 595 | if (NULL != disconnect_task) |
580 | { | 596 | { |
581 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 597 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
582 | " reschedule timeout every 10 messages\n"); | 598 | "reschedule timeout every 10 messages\n"); |
583 | GNUNET_SCHEDULER_cancel (disconnect_task); | 599 | GNUNET_SCHEDULER_cancel (disconnect_task); |
584 | disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time, | 600 | disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time, |
585 | &gather_stats_and_exit, | 601 | &gather_stats_and_exit, |
@@ -613,7 +629,8 @@ check_data (void *cls, const struct GNUNET_MessageHeader *message) | |||
613 | * @param message the actual message | 629 | * @param message the actual message |
614 | */ | 630 | */ |
615 | static void | 631 | static void |
616 | handle_data (void *cls, const struct GNUNET_MessageHeader *message) | 632 | handle_data (void *cls, |
633 | const struct GNUNET_MessageHeader *message) | ||
617 | { | 634 | { |
618 | struct CadetTestChannelWrapper *ch = cls; | 635 | struct CadetTestChannelWrapper *ch = cls; |
619 | struct GNUNET_CADET_Channel *channel = ch->ch; | 636 | struct GNUNET_CADET_Channel *channel = ch->ch; |
@@ -778,19 +795,21 @@ connect_handler (void *cls, struct GNUNET_CADET_Channel *channel, | |||
778 | * @param channel Connection to the other end (henceforth invalid). | 795 | * @param channel Connection to the other end (henceforth invalid). |
779 | */ | 796 | */ |
780 | static void | 797 | static void |
781 | disconnect_handler (void *cls, const struct GNUNET_CADET_Channel *channel) | 798 | disconnect_handler (void *cls, |
799 | const struct GNUNET_CADET_Channel *channel) | ||
782 | { | 800 | { |
783 | struct CadetTestChannelWrapper *ch_w = cls; | 801 | struct CadetTestChannelWrapper *ch_w = cls; |
784 | 802 | ||
785 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Channel disconnected\n"); | 803 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
804 | "Channel disconnected at %d\n", | ||
805 | ok); | ||
786 | GNUNET_assert (ch_w->ch == channel); | 806 | GNUNET_assert (ch_w->ch == channel); |
787 | if (channel == incoming_ch) | 807 | if (channel == incoming_ch) |
788 | { | 808 | { |
789 | ok++; | 809 | ok++; |
790 | incoming_ch = NULL; | 810 | incoming_ch = NULL; |
791 | } | 811 | } |
792 | else if (outgoing_ch == channel | 812 | else if (outgoing_ch == channel) |
793 | ) | ||
794 | { | 813 | { |
795 | if (P2P_SIGNAL == test) | 814 | if (P2P_SIGNAL == test) |
796 | { | 815 | { |
@@ -799,14 +818,15 @@ disconnect_handler (void *cls, const struct GNUNET_CADET_Channel *channel) | |||
799 | outgoing_ch = NULL; | 818 | outgoing_ch = NULL; |
800 | } | 819 | } |
801 | else | 820 | else |
802 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unknown channel! %p\n", channel); | 821 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
803 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok); | 822 | "Unknown channel! %p\n", |
804 | 823 | channel); | |
805 | if (NULL != disconnect_task) | 824 | if (NULL != disconnect_task) |
806 | { | 825 | { |
807 | GNUNET_SCHEDULER_cancel (disconnect_task); | 826 | GNUNET_SCHEDULER_cancel (disconnect_task); |
808 | disconnect_task = | 827 | disconnect_task = |
809 | GNUNET_SCHEDULER_add_now (&gather_stats_and_exit, (void *) __LINE__); | 828 | GNUNET_SCHEDULER_add_now (&gather_stats_and_exit, |
829 | (void *) __LINE__); | ||
810 | } | 830 | } |
811 | } | 831 | } |
812 | 832 | ||
@@ -887,25 +907,34 @@ start_test (void *cls) | |||
887 | * NULL if the operation is successfull | 907 | * NULL if the operation is successfull |
888 | */ | 908 | */ |
889 | static void | 909 | static void |
890 | pi_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | 910 | pi_cb (void *cls, |
891 | const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg) | 911 | struct GNUNET_TESTBED_Operation *op, |
912 | const struct GNUNET_TESTBED_PeerInformation *pinfo, | ||
913 | const char *emsg) | ||
892 | { | 914 | { |
893 | long i = (long) cls; | 915 | long i = (long) cls; |
894 | 916 | ||
895 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ID callback for %ld\n", i); | 917 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
896 | 918 | "ID callback for %ld\n", | |
897 | if ((NULL == pinfo) || (NULL != emsg)) | 919 | i); |
920 | if ( (NULL == pinfo) || | ||
921 | (NULL != emsg) ) | ||
898 | { | 922 | { |
899 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg); | 923 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
924 | "pi_cb: %s\n", | ||
925 | emsg); | ||
900 | abort_test (__LINE__); | 926 | abort_test (__LINE__); |
901 | return; | 927 | return; |
902 | } | 928 | } |
903 | p_id[i] = pinfo->result.id; | 929 | p_id[i] = pinfo->result.id; |
904 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " id: %s\n", GNUNET_i2s (p_id[i])); | 930 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
931 | "id: %s\n", | ||
932 | GNUNET_i2s (p_id[i])); | ||
905 | p_ids++; | 933 | p_ids++; |
906 | if (p_ids < 2) | 934 | if (p_ids < 2) |
907 | return; | 935 | return; |
908 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got all IDs, starting test\n"); | 936 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
937 | "Got all IDs, starting test\n"); | ||
909 | test_task = GNUNET_SCHEDULER_add_now (&start_test, NULL); | 938 | test_task = GNUNET_SCHEDULER_add_now (&start_test, NULL); |
910 | } | 939 | } |
911 | 940 | ||
@@ -937,7 +966,8 @@ tmain (void *cls, | |||
937 | disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time, | 966 | disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time, |
938 | &disconnect_cadet_peers, | 967 | &disconnect_cadet_peers, |
939 | (void *) __LINE__); | 968 | (void *) __LINE__); |
940 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 969 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
970 | NULL); | ||
941 | t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0], | 971 | t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0], |
942 | GNUNET_TESTBED_PIT_IDENTITY, | 972 | GNUNET_TESTBED_PIT_IDENTITY, |
943 | &pi_cb, | 973 | &pi_cb, |