diff options
-rw-r--r-- | src/cadet/Makefile.am | 12 | ||||
-rw-r--r-- | src/cadet/test_cadet.c | 261 | ||||
-rw-r--r-- | src/rps/gnunet-rps-profiler.c | 20 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps.c | 248 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps_custommap.c | 1 | ||||
-rw-r--r-- | src/rps/rps-test_util.c | 2 | ||||
-rw-r--r-- | src/rps/test_rps.c | 2 | ||||
-rw-r--r-- | src/rps/test_rps.conf | 1 |
8 files changed, 313 insertions, 234 deletions
diff --git a/src/cadet/Makefile.am b/src/cadet/Makefile.am index ce30ebe46..b2d436061 100644 --- a/src/cadet/Makefile.am +++ b/src/cadet/Makefile.am | |||
@@ -90,6 +90,7 @@ check_PROGRAMS = \ | |||
90 | test_cadet_2_speed_backwards \ | 90 | test_cadet_2_speed_backwards \ |
91 | test_cadet_2_speed_reliable \ | 91 | test_cadet_2_speed_reliable \ |
92 | test_cadet_2_speed_reliable_backwards \ | 92 | test_cadet_2_speed_reliable_backwards \ |
93 | test_cadet_2_reopen \ | ||
93 | test_cadet_5_forward \ | 94 | test_cadet_5_forward \ |
94 | test_cadet_5_signal \ | 95 | test_cadet_5_signal \ |
95 | test_cadet_5_keepalive \ | 96 | test_cadet_5_keepalive \ |
@@ -97,7 +98,8 @@ check_PROGRAMS = \ | |||
97 | test_cadet_5_speed_ack \ | 98 | test_cadet_5_speed_ack \ |
98 | test_cadet_5_speed_reliable \ | 99 | test_cadet_5_speed_reliable \ |
99 | test_cadet_5_speed_reliable_backwards \ | 100 | test_cadet_5_speed_reliable_backwards \ |
100 | test_cadet_5_speed_backwards | 101 | test_cadet_5_speed_backwards \ |
102 | test_cadet_5_reopen | ||
101 | endif | 103 | endif |
102 | 104 | ||
103 | 105 | ||
@@ -197,6 +199,14 @@ test_cadet_5_speed_reliable_backwards_SOURCES = \ | |||
197 | test_cadet.c | 199 | test_cadet.c |
198 | test_cadet_5_speed_reliable_backwards_LDADD = $(ld_cadet_test_lib) | 200 | test_cadet_5_speed_reliable_backwards_LDADD = $(ld_cadet_test_lib) |
199 | 201 | ||
202 | test_cadet_2_reopen_SOURCES = \ | ||
203 | test_cadet.c | ||
204 | test_cadet_2_reopen_LDADD = $(ld_cadet_test_lib) | ||
205 | |||
206 | test_cadet_5_reopen_SOURCES = \ | ||
207 | test_cadet.c | ||
208 | test_cadet_5_reopen_LDADD = $(ld_cadet_test_lib) | ||
209 | |||
200 | 210 | ||
201 | if ENABLE_TEST_RUN | 211 | if ENABLE_TEST_RUN |
202 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 212 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c index 5187bc504..76ff258e0 100644 --- a/src/cadet/test_cadet.c +++ b/src/cadet/test_cadet.c | |||
@@ -70,6 +70,7 @@ struct CadetTestChannelWrapper | |||
70 | #define SPEED_ACK 4 | 70 | #define SPEED_ACK 4 |
71 | #define SPEED_REL 8 | 71 | #define SPEED_REL 8 |
72 | #define P2P_SIGNAL 10 | 72 | #define P2P_SIGNAL 10 |
73 | #define REOPEN 11 | ||
73 | 74 | ||
74 | /** | 75 | /** |
75 | * Which test are we running? | 76 | * Which test are we running? |
@@ -177,6 +178,11 @@ struct GNUNET_CADET_TEST_Context *test_ctx; | |||
177 | static struct GNUNET_SCHEDULER_Task *disconnect_task; | 178 | static struct GNUNET_SCHEDULER_Task *disconnect_task; |
178 | 179 | ||
179 | /** | 180 | /** |
181 | * Task called to reconnect peers. | ||
182 | */ | ||
183 | static struct GNUNET_SCHEDULER_Task *reconnect_task; | ||
184 | |||
185 | /** | ||
180 | * Task To perform tests | 186 | * Task To perform tests |
181 | */ | 187 | */ |
182 | static struct GNUNET_SCHEDULER_Task *test_task; | 188 | static struct GNUNET_SCHEDULER_Task *test_task; |
@@ -374,7 +380,8 @@ stats_cont (void *cls, | |||
374 | "KA sent: %u, KA received: %u\n", | 380 | "KA sent: %u, KA received: %u\n", |
375 | ka_sent, | 381 | ka_sent, |
376 | ka_received); | 382 | ka_received); |
377 | if ((KEEPALIVE == test) && ((ka_sent < 2) || (ka_sent > ka_received + 1))) | 383 | if ((KEEPALIVE == test || REOPEN == test) && |
384 | ((ka_sent < 2) || (ka_sent > ka_received + 1))) | ||
378 | { | 385 | { |
379 | GNUNET_break (0); | 386 | GNUNET_break (0); |
380 | ok--; | 387 | ok--; |
@@ -459,6 +466,152 @@ gather_stats_and_exit (void *cls) | |||
459 | 466 | ||
460 | 467 | ||
461 | /** | 468 | /** |
469 | * Send a message on the channel with the appropriate size and payload. | ||
470 | * | ||
471 | * Update the appropriate *_sent counter. | ||
472 | * | ||
473 | * @param channel Channel to send the message on. | ||
474 | */ | ||
475 | static void | ||
476 | send_test_message (struct GNUNET_CADET_Channel *channel); | ||
477 | |||
478 | /** | ||
479 | * Check if payload is sane (size contains payload). | ||
480 | * | ||
481 | * @param cls should match #ch | ||
482 | * @param message The actual message. | ||
483 | * @return #GNUNET_OK to keep the channel open, | ||
484 | * #GNUNET_SYSERR to close it (signal serious error). | ||
485 | */ | ||
486 | static int | ||
487 | check_data (void *cls, | ||
488 | const struct GNUNET_MessageHeader *message); | ||
489 | |||
490 | /** | ||
491 | * Function is called whenever a message is received. | ||
492 | * | ||
493 | * @param cls closure (set from GNUNET_CADET_connect(), peer number) | ||
494 | * @param message the actual message | ||
495 | */ | ||
496 | static void | ||
497 | handle_data (void *cls, | ||
498 | const struct GNUNET_MessageHeader *message); | ||
499 | |||
500 | /** | ||
501 | * Function called whenever an MQ-channel is destroyed, even if the destruction | ||
502 | * was requested by #GNUNET_CADET_channel_destroy. | ||
503 | * It must NOT call #GNUNET_CADET_channel_destroy on the channel. | ||
504 | * | ||
505 | * It should clean up any associated state, including cancelling any pending | ||
506 | * transmission on this channel. | ||
507 | * | ||
508 | * @param cls Channel closure (channel wrapper). | ||
509 | * @param channel Connection to the other end (henceforth invalid). | ||
510 | */ | ||
511 | static void | ||
512 | disconnect_handler (void *cls, | ||
513 | const struct GNUNET_CADET_Channel *channel); | ||
514 | |||
515 | |||
516 | /** | ||
517 | * Task to reconnect to other peer. | ||
518 | * | ||
519 | * @param cls Closure (line from which the task was scheduled). | ||
520 | */ | ||
521 | static void | ||
522 | reconnect_op (void *cls) | ||
523 | { | ||
524 | struct GNUNET_MQ_MessageHandler handlers[] = { | ||
525 | GNUNET_MQ_hd_var_size (data, | ||
526 | GNUNET_MESSAGE_TYPE_DUMMY, | ||
527 | struct GNUNET_MessageHeader, | ||
528 | NULL), | ||
529 | GNUNET_MQ_handler_end () | ||
530 | }; | ||
531 | long l = (long) cls; | ||
532 | struct CadetTestChannelWrapper *ch; | ||
533 | enum GNUNET_CADET_ChannelOption flags; | ||
534 | |||
535 | reconnect_task = NULL; | ||
536 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
537 | "reconnecting from line %ld\n", | ||
538 | l); | ||
539 | if (NULL != outgoing_ch) | ||
540 | { | ||
541 | GNUNET_CADET_channel_destroy (outgoing_ch); | ||
542 | outgoing_ch = NULL; | ||
543 | } | ||
544 | flags = GNUNET_CADET_OPTION_DEFAULT; | ||
545 | ch = GNUNET_new (struct CadetTestChannelWrapper); | ||
546 | outgoing_ch = GNUNET_CADET_channel_create (h1, | ||
547 | ch, | ||
548 | p_id[1], | ||
549 | &port, | ||
550 | flags, | ||
551 | NULL, | ||
552 | &disconnect_handler, | ||
553 | handlers); | ||
554 | ch->ch = outgoing_ch; | ||
555 | send_test_message (outgoing_ch); | ||
556 | } | ||
557 | |||
558 | /** | ||
559 | * Function called whenever an MQ-channel is destroyed, even if the destruction | ||
560 | * was requested by #GNUNET_CADET_channel_destroy. | ||
561 | * It must NOT call #GNUNET_CADET_channel_destroy on the channel. | ||
562 | * | ||
563 | * It should clean up any associated state, including cancelling any pending | ||
564 | * transmission on this channel. | ||
565 | * | ||
566 | * @param cls Channel closure (channel wrapper). | ||
567 | * @param channel Connection to the other end (henceforth invalid). | ||
568 | */ | ||
569 | static void | ||
570 | disconnect_handler (void *cls, | ||
571 | const struct GNUNET_CADET_Channel *channel) | ||
572 | { | ||
573 | struct CadetTestChannelWrapper *ch_w = cls; | ||
574 | |||
575 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
576 | "Channel disconnected at %d\n", | ||
577 | ok); | ||
578 | GNUNET_assert (ch_w->ch == channel); | ||
579 | if (channel == incoming_ch) | ||
580 | { | ||
581 | ok++; | ||
582 | incoming_ch = NULL; | ||
583 | } | ||
584 | else if (outgoing_ch == channel) | ||
585 | { | ||
586 | if (P2P_SIGNAL == test) | ||
587 | { | ||
588 | ok++; | ||
589 | } | ||
590 | outgoing_ch = NULL; | ||
591 | } | ||
592 | else | ||
593 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
594 | "Unknown channel! %p\n", | ||
595 | channel); | ||
596 | if (NULL != disconnect_task && REOPEN != test) | ||
597 | { | ||
598 | GNUNET_SCHEDULER_cancel (disconnect_task); | ||
599 | disconnect_task = | ||
600 | GNUNET_SCHEDULER_add_now (&gather_stats_and_exit, | ||
601 | (void *) __LINE__); | ||
602 | } | ||
603 | else if (NULL != reconnect_task && REOPEN == test) | ||
604 | { | ||
605 | GNUNET_SCHEDULER_cancel (reconnect_task); | ||
606 | reconnect_task = | ||
607 | GNUNET_SCHEDULER_add_now (&reconnect_op, | ||
608 | (void *) __LINE__); | ||
609 | } | ||
610 | GNUNET_free (ch_w); | ||
611 | } | ||
612 | |||
613 | |||
614 | /** | ||
462 | * Abort test: schedule disconnect and shutdown immediately | 615 | * Abort test: schedule disconnect and shutdown immediately |
463 | * | 616 | * |
464 | * @param line Line in the code the abort is requested from (__LINE__). | 617 | * @param line Line in the code the abort is requested from (__LINE__). |
@@ -536,6 +689,14 @@ send_test_message (struct GNUNET_CADET_Channel *channel) | |||
536 | { | 689 | { |
537 | payload = data_sent; | 690 | payload = data_sent; |
538 | } | 691 | } |
692 | else if (REOPEN == test) | ||
693 | { | ||
694 | payload = data_sent; | ||
695 | data_sent++; | ||
696 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
697 | "Sending DATA %u [%d bytes]\n", | ||
698 | data_sent, size); | ||
699 | } | ||
539 | else | 700 | else |
540 | { | 701 | { |
541 | GNUNET_assert (0); | 702 | GNUNET_assert (0); |
@@ -784,13 +945,29 @@ connect_handler (void *cls, | |||
784 | (long) cls); | 945 | (long) cls); |
785 | GNUNET_assert (0); | 946 | GNUNET_assert (0); |
786 | } | 947 | } |
787 | if (NULL != disconnect_task) | 948 | if (NULL != disconnect_task && REOPEN != test) |
788 | { | 949 | { |
789 | GNUNET_SCHEDULER_cancel (disconnect_task); | 950 | GNUNET_SCHEDULER_cancel (disconnect_task); |
790 | disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time, | 951 | disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time, |
791 | &gather_stats_and_exit, | 952 | &gather_stats_and_exit, |
792 | (void *) __LINE__); | 953 | (void *) __LINE__); |
793 | } | 954 | } |
955 | else if ((NULL != disconnect_task) && (REOPEN == test)) | ||
956 | { | ||
957 | GNUNET_SCHEDULER_cancel (disconnect_task); | ||
958 | disconnect_task = GNUNET_SCHEDULER_add_delayed ( | ||
959 | GNUNET_TIME_relative_multiply (short_time, 2), | ||
960 | &gather_stats_and_exit, | ||
961 | (void *) __LINE__); | ||
962 | } | ||
963 | |||
964 | if ((NULL != reconnect_task) && (REOPEN == test)) | ||
965 | { | ||
966 | GNUNET_SCHEDULER_cancel (reconnect_task); | ||
967 | reconnect_task = GNUNET_SCHEDULER_add_delayed (short_time, | ||
968 | &reconnect_op, | ||
969 | (void *) __LINE__); | ||
970 | } | ||
794 | 971 | ||
795 | /* TODO: cannot return channel as-is, in order to unify the data handlers */ | 972 | /* TODO: cannot return channel as-is, in order to unify the data handlers */ |
796 | ch = GNUNET_new (struct CadetTestChannelWrapper); | 973 | ch = GNUNET_new (struct CadetTestChannelWrapper); |
@@ -801,55 +978,6 @@ connect_handler (void *cls, | |||
801 | 978 | ||
802 | 979 | ||
803 | /** | 980 | /** |
804 | * Function called whenever an MQ-channel is destroyed, even if the destruction | ||
805 | * was requested by #GNUNET_CADET_channel_destroy. | ||
806 | * It must NOT call #GNUNET_CADET_channel_destroy on the channel. | ||
807 | * | ||
808 | * It should clean up any associated state, including cancelling any pending | ||
809 | * transmission on this channel. | ||
810 | * | ||
811 | * @param cls Channel closure (channel wrapper). | ||
812 | * @param channel Connection to the other end (henceforth invalid). | ||
813 | */ | ||
814 | static void | ||
815 | disconnect_handler (void *cls, | ||
816 | const struct GNUNET_CADET_Channel *channel) | ||
817 | { | ||
818 | struct CadetTestChannelWrapper *ch_w = cls; | ||
819 | |||
820 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
821 | "Channel disconnected at %d\n", | ||
822 | ok); | ||
823 | GNUNET_assert (ch_w->ch == channel); | ||
824 | if (channel == incoming_ch) | ||
825 | { | ||
826 | ok++; | ||
827 | incoming_ch = NULL; | ||
828 | } | ||
829 | else if (outgoing_ch == channel) | ||
830 | { | ||
831 | if (P2P_SIGNAL == test) | ||
832 | { | ||
833 | ok++; | ||
834 | } | ||
835 | outgoing_ch = NULL; | ||
836 | } | ||
837 | else | ||
838 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
839 | "Unknown channel! %p\n", | ||
840 | channel); | ||
841 | if (NULL != disconnect_task) | ||
842 | { | ||
843 | GNUNET_SCHEDULER_cancel (disconnect_task); | ||
844 | disconnect_task = | ||
845 | GNUNET_SCHEDULER_add_now (&gather_stats_and_exit, | ||
846 | (void *) __LINE__); | ||
847 | } | ||
848 | GNUNET_free (ch_w); | ||
849 | } | ||
850 | |||
851 | |||
852 | /** | ||
853 | * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES. | 981 | * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES. |
854 | * | 982 | * |
855 | * Testcase continues when the root receives confirmation of connected peers, | 983 | * Testcase continues when the root receives confirmation of connected peers, |
@@ -871,7 +999,7 @@ start_test (void *cls) | |||
871 | enum GNUNET_CADET_ChannelOption flags; | 999 | enum GNUNET_CADET_ChannelOption flags; |
872 | 1000 | ||
873 | test_task = NULL; | 1001 | test_task = NULL; |
874 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test\n"); | 1002 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test: %s\n", test_name); |
875 | if (NULL != disconnect_task) | 1003 | if (NULL != disconnect_task) |
876 | { | 1004 | { |
877 | GNUNET_SCHEDULER_cancel (disconnect_task); | 1005 | GNUNET_SCHEDULER_cancel (disconnect_task); |
@@ -903,7 +1031,6 @@ start_test (void *cls) | |||
903 | if (KEEPALIVE == test) | 1031 | if (KEEPALIVE == test) |
904 | return; /* Don't send any data. */ | 1032 | return; /* Don't send any data. */ |
905 | 1033 | ||
906 | |||
907 | data_received = 0; | 1034 | data_received = 0; |
908 | data_sent = 0; | 1035 | data_sent = 0; |
909 | ack_received = 0; | 1036 | ack_received = 0; |
@@ -912,6 +1039,18 @@ start_test (void *cls) | |||
912 | "Sending data initializer on channel %p...\n", | 1039 | "Sending data initializer on channel %p...\n", |
913 | outgoing_ch); | 1040 | outgoing_ch); |
914 | send_test_message (outgoing_ch); | 1041 | send_test_message (outgoing_ch); |
1042 | if (REOPEN == test) | ||
1043 | { | ||
1044 | reconnect_task = GNUNET_SCHEDULER_add_delayed (short_time, | ||
1045 | &reconnect_op, | ||
1046 | (void *) __LINE__); | ||
1047 | GNUNET_SCHEDULER_cancel (disconnect_task); | ||
1048 | disconnect_task = GNUNET_SCHEDULER_add_delayed ( | ||
1049 | GNUNET_TIME_relative_multiply (short_time, 2), | ||
1050 | &gather_stats_and_exit, | ||
1051 | (void *) __LINE__); | ||
1052 | } | ||
1053 | |||
915 | } | 1054 | } |
916 | 1055 | ||
917 | 1056 | ||
@@ -1055,6 +1194,11 @@ main (int argc, char *argv[]) | |||
1055 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n"); | 1194 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n"); |
1056 | peers_requested = 5; | 1195 | peers_requested = 5; |
1057 | } | 1196 | } |
1197 | else if (strstr (argv[0], "_6_") != NULL) | ||
1198 | { | ||
1199 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "6 PEER LINE\n"); | ||
1200 | peers_requested = 6; | ||
1201 | } | ||
1058 | else | 1202 | else |
1059 | { | 1203 | { |
1060 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n"); | 1204 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n"); |
@@ -1122,6 +1266,17 @@ main (int argc, char *argv[]) | |||
1122 | */ | 1266 | */ |
1123 | ok_goal = 2; | 1267 | ok_goal = 2; |
1124 | } | 1268 | } |
1269 | else if (strstr (argv[0], "_reopen") != NULL) | ||
1270 | { | ||
1271 | test = REOPEN; | ||
1272 | test_name = "reopen"; | ||
1273 | ///* Test is supposed to generate the following callbacks: | ||
1274 | // * 1 incoming channel (@dest) | ||
1275 | // * [wait] | ||
1276 | // * 1 received channel destroy (@dest) | ||
1277 | // */ | ||
1278 | ok_goal = 7; | ||
1279 | } | ||
1125 | else | 1280 | else |
1126 | { | 1281 | { |
1127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n"); | 1282 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n"); |
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c index 49714872f..277688b56 100644 --- a/src/rps/gnunet-rps-profiler.c +++ b/src/rps/gnunet-rps-profiler.c | |||
@@ -2311,14 +2311,14 @@ void write_final_stats (void){ | |||
2311 | 2311 | ||
2312 | for (uint32_t i = 0; i < num_peers; i++) | 2312 | for (uint32_t i = 0; i < num_peers; i++) |
2313 | { | 2313 | { |
2314 | to_file ("/tmp/rps/final_stats.dat", | 2314 | to_file ("/tmp/rps/final_stats.csv", |
2315 | "%" PRIu32 " " /* index */ | 2315 | ", %" PRIu32 ", " /* index */ |
2316 | "%s %" /* id */ | 2316 | "%s, %" /* id */ |
2317 | PRIu64 " %" /* rounds */ | 2317 | PRIu64 ", %" /* rounds */ |
2318 | PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" /* blocking */ | 2318 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* blocking */ |
2319 | PRIu64 " %" PRIu64 " %" PRIu64 " %" /* issued */ | 2319 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* issued */ |
2320 | PRIu64 " %" PRIu64 " %" PRIu64 " %" /* sent */ | 2320 | PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* sent */ |
2321 | PRIu64 " %" PRIu64 " %" PRIu64 /* recv */, | 2321 | PRIu64 ", %" PRIu64 ", %" PRIu64 /* recv */, |
2322 | i, | 2322 | i, |
2323 | GNUNET_i2s (rps_peers[i].peer_id), | 2323 | GNUNET_i2s (rps_peers[i].peer_id), |
2324 | rps_peers[i].stats[STAT_TYPE_ROUNDS], | 2324 | rps_peers[i].stats[STAT_TYPE_ROUNDS], |
@@ -2407,10 +2407,10 @@ post_test_shutdown_ready_cb (void *cls, | |||
2407 | GNUNET_TESTBED_operation_done (rps_peer->stat_op); | 2407 | GNUNET_TESTBED_operation_done (rps_peer->stat_op); |
2408 | } | 2408 | } |
2409 | 2409 | ||
2410 | write_final_stats (); | 2410 | //write_final_stats (); |
2411 | if (GNUNET_YES == check_statistics_collect_completed()) | 2411 | if (GNUNET_YES == check_statistics_collect_completed()) |
2412 | { | 2412 | { |
2413 | //write_final_stats (); | 2413 | write_final_stats (); |
2414 | GNUNET_free (stat_cls); | 2414 | GNUNET_free (stat_cls); |
2415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2416 | "Shutting down\n"); | 2416 | "Shutting down\n"); |
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 6b0ecc58c..8e8320a53 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -233,11 +233,6 @@ struct PeerContext | |||
233 | struct PendingMessage *pending_messages_tail; | 233 | struct PendingMessage *pending_messages_tail; |
234 | 234 | ||
235 | /** | 235 | /** |
236 | * @brief Task to destroy this context. | ||
237 | */ | ||
238 | struct GNUNET_SCHEDULER_Task *destruction_task; | ||
239 | |||
240 | /** | ||
241 | * This is pobably followed by 'statistical' data (when we first saw | 236 | * This is pobably followed by 'statistical' data (when we first saw |
242 | * it, how did we get its ID, how many pushes (in a timeinterval), | 237 | * it, how did we get its ID, how many pushes (in a timeinterval), |
243 | * ...) | 238 | * ...) |
@@ -280,11 +275,6 @@ struct ChannelCtx | |||
280 | * @brief The peer context associated with the channel | 275 | * @brief The peer context associated with the channel |
281 | */ | 276 | */ |
282 | struct PeerContext *peer_ctx; | 277 | struct PeerContext *peer_ctx; |
283 | |||
284 | /** | ||
285 | * @brief Scheduled task that will destroy this context | ||
286 | */ | ||
287 | struct GNUNET_SCHEDULER_Task *destruction_task; | ||
288 | }; | 278 | }; |
289 | 279 | ||
290 | /** | 280 | /** |
@@ -335,8 +325,28 @@ get_peer_ctx (const struct GNUNET_PeerIdentity *peer) | |||
335 | return ctx; | 325 | return ctx; |
336 | } | 326 | } |
337 | 327 | ||
338 | int | 328 | /** |
339 | Peers_check_peer_known (const struct GNUNET_PeerIdentity *peer); | 329 | * @brief Check whether we have information about the given peer. |
330 | * | ||
331 | * FIXME probably deprecated. Make this the new _online. | ||
332 | * | ||
333 | * @param peer peer in question | ||
334 | * | ||
335 | * @return #GNUNET_YES if peer is known | ||
336 | * #GNUNET_NO if peer is not knwon | ||
337 | */ | ||
338 | static int | ||
339 | Peers_check_peer_known (const struct GNUNET_PeerIdentity *peer) | ||
340 | { | ||
341 | if (NULL != peer_map) | ||
342 | { | ||
343 | return GNUNET_CONTAINER_multipeermap_contains (peer_map, peer); | ||
344 | } else | ||
345 | { | ||
346 | return GNUNET_NO; | ||
347 | } | ||
348 | } | ||
349 | |||
340 | 350 | ||
341 | /** | 351 | /** |
342 | * @brief Create a new #PeerContext and insert it into the peer map | 352 | * @brief Create a new #PeerContext and insert it into the peer map |
@@ -379,11 +389,37 @@ create_or_get_peer_ctx (const struct GNUNET_PeerIdentity *peer) | |||
379 | return get_peer_ctx (peer); | 389 | return get_peer_ctx (peer); |
380 | } | 390 | } |
381 | 391 | ||
382 | void | ||
383 | Peers_unset_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags); | ||
384 | 392 | ||
385 | void | 393 | /** |
386 | Peers_set_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags); | 394 | * @brief unset flags on a given peer. |
395 | * | ||
396 | * @param peer the peer to unset flags on | ||
397 | * @param flags the flags | ||
398 | */ | ||
399 | static void | ||
400 | Peers_unset_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags) | ||
401 | { | ||
402 | struct PeerContext *peer_ctx; | ||
403 | |||
404 | peer_ctx = get_peer_ctx (peer); | ||
405 | unset_peer_flag (peer_ctx, flags); | ||
406 | } | ||
407 | |||
408 | |||
409 | /** | ||
410 | * @brief set flags on a given peer. | ||
411 | * | ||
412 | * @param peer the peer to set flags on | ||
413 | * @param flags the flags | ||
414 | */ | ||
415 | static void | ||
416 | Peers_set_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags) | ||
417 | { | ||
418 | struct PeerContext *peer_ctx; | ||
419 | |||
420 | peer_ctx = get_peer_ctx (peer); | ||
421 | set_peer_flag (peer_ctx, flags); | ||
422 | } | ||
387 | 423 | ||
388 | /** | 424 | /** |
389 | * @brief Check whether we have a connection to this @a peer | 425 | * @brief Check whether we have a connection to this @a peer |
@@ -395,7 +431,7 @@ Peers_set_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlag | |||
395 | * @return #GNUNET_YES if we are connected | 431 | * @return #GNUNET_YES if we are connected |
396 | * #GNUNET_NO otherwise | 432 | * #GNUNET_NO otherwise |
397 | */ | 433 | */ |
398 | int | 434 | static int |
399 | Peers_check_connected (const struct GNUNET_PeerIdentity *peer) | 435 | Peers_check_connected (const struct GNUNET_PeerIdentity *peer) |
400 | { | 436 | { |
401 | const struct PeerContext *peer_ctx; | 437 | const struct PeerContext *peer_ctx; |
@@ -1084,7 +1120,7 @@ restore_valid_peers () | |||
1084 | * @param cadet_h cadet handle | 1120 | * @param cadet_h cadet handle |
1085 | * @param own_id own peer identity | 1121 | * @param own_id own peer identity |
1086 | */ | 1122 | */ |
1087 | void | 1123 | static void |
1088 | Peers_initialise (char* fn_valid_peers, | 1124 | Peers_initialise (char* fn_valid_peers, |
1089 | struct GNUNET_CADET_Handle *cadet_h) | 1125 | struct GNUNET_CADET_Handle *cadet_h) |
1090 | { | 1126 | { |
@@ -1150,7 +1186,7 @@ valid_peer_iterator (void *cls, | |||
1150 | * @return the number of key value pairs processed, | 1186 | * @return the number of key value pairs processed, |
1151 | * #GNUNET_SYSERR if it aborted iteration | 1187 | * #GNUNET_SYSERR if it aborted iteration |
1152 | */ | 1188 | */ |
1153 | int | 1189 | static int |
1154 | Peers_get_valid_peers (PeersIterator iterator, | 1190 | Peers_get_valid_peers (PeersIterator iterator, |
1155 | void *it_cls) | 1191 | void *it_cls) |
1156 | { | 1192 | { |
@@ -1179,7 +1215,7 @@ Peers_get_valid_peers (PeersIterator iterator, | |||
1179 | * @return #GNUNET_YES if peer was inserted | 1215 | * @return #GNUNET_YES if peer was inserted |
1180 | * #GNUNET_NO otherwise | 1216 | * #GNUNET_NO otherwise |
1181 | */ | 1217 | */ |
1182 | int | 1218 | static int |
1183 | Peers_insert_peer (const struct GNUNET_PeerIdentity *peer) | 1219 | Peers_insert_peer (const struct GNUNET_PeerIdentity *peer) |
1184 | { | 1220 | { |
1185 | if (GNUNET_YES == Peers_check_peer_known (peer)) | 1221 | if (GNUNET_YES == Peers_check_peer_known (peer)) |
@@ -1190,7 +1226,7 @@ Peers_insert_peer (const struct GNUNET_PeerIdentity *peer) | |||
1190 | return GNUNET_YES; | 1226 | return GNUNET_YES; |
1191 | } | 1227 | } |
1192 | 1228 | ||
1193 | int | 1229 | static int |
1194 | Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags); | 1230 | Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags); |
1195 | 1231 | ||
1196 | /** | 1232 | /** |
@@ -1202,7 +1238,7 @@ Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFl | |||
1202 | * @return #GNUNET_YES if peer had to be inserted | 1238 | * @return #GNUNET_YES if peer had to be inserted |
1203 | * #GNUNET_NO otherwise | 1239 | * #GNUNET_NO otherwise |
1204 | */ | 1240 | */ |
1205 | int | 1241 | static int |
1206 | Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) | 1242 | Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) |
1207 | { | 1243 | { |
1208 | struct PeerContext *peer_ctx; | 1244 | struct PeerContext *peer_ctx; |
@@ -1232,7 +1268,7 @@ Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) | |||
1232 | * #GNUNET_NO if peer is NOT removable | 1268 | * #GNUNET_NO if peer is NOT removable |
1233 | * #GNUNET_SYSERR if peer is not known | 1269 | * #GNUNET_SYSERR if peer is not known |
1234 | */ | 1270 | */ |
1235 | int | 1271 | static int |
1236 | Peers_check_removable (const struct GNUNET_PeerIdentity *peer) | 1272 | Peers_check_removable (const struct GNUNET_PeerIdentity *peer) |
1237 | { | 1273 | { |
1238 | struct PeerContext *peer_ctx; | 1274 | struct PeerContext *peer_ctx; |
@@ -1252,11 +1288,11 @@ Peers_check_removable (const struct GNUNET_PeerIdentity *peer) | |||
1252 | return GNUNET_YES; | 1288 | return GNUNET_YES; |
1253 | } | 1289 | } |
1254 | 1290 | ||
1255 | uint32_t * | 1291 | static uint32_t * |
1256 | Peers_get_channel_flag (const struct GNUNET_PeerIdentity *peer, | 1292 | Peers_get_channel_flag (const struct GNUNET_PeerIdentity *peer, |
1257 | enum Peers_ChannelRole role); | 1293 | enum Peers_ChannelRole role); |
1258 | 1294 | ||
1259 | int | 1295 | static int |
1260 | Peers_check_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags); | 1296 | Peers_check_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags); |
1261 | 1297 | ||
1262 | /** | 1298 | /** |
@@ -1270,54 +1306,26 @@ destroy_peer (void *cls) | |||
1270 | struct PeerContext *peer_ctx = cls; | 1306 | struct PeerContext *peer_ctx = cls; |
1271 | 1307 | ||
1272 | GNUNET_assert (NULL != peer_ctx); | 1308 | GNUNET_assert (NULL != peer_ctx); |
1273 | peer_ctx->destruction_task = NULL; | ||
1274 | Peers_remove_peer (&peer_ctx->peer_id); | 1309 | Peers_remove_peer (&peer_ctx->peer_id); |
1275 | } | 1310 | } |
1276 | 1311 | ||
1277 | 1312 | ||
1278 | static void | ||
1279 | destroy_channel (void *cls); | ||
1280 | |||
1281 | |||
1282 | /** | 1313 | /** |
1283 | * @brief Schedule the destruction of the given channel. | 1314 | * @brief Callback for scheduler to destroy a channel |
1284 | * | ||
1285 | * Do so only if it was not already scheduled and not during shutdown. | ||
1286 | * | 1315 | * |
1287 | * @param channel_ctx The context of the channel to destroy. | 1316 | * @param cls Context of the channel |
1288 | */ | 1317 | */ |
1289 | static void | 1318 | static void |
1290 | schedule_channel_destruction (struct ChannelCtx *channel_ctx) | 1319 | destroy_channel (void *cls) |
1291 | { | 1320 | { |
1292 | GNUNET_assert (NULL != channel_ctx); | 1321 | struct ChannelCtx *channel_ctx = cls; |
1293 | if (NULL != channel_ctx->destruction_task && | 1322 | struct PeerContext *peer_ctx = channel_ctx->peer_ctx; |
1294 | GNUNET_NO == in_shutdown) | ||
1295 | { | ||
1296 | channel_ctx->destruction_task = | ||
1297 | GNUNET_SCHEDULER_add_now (&destroy_channel, | ||
1298 | channel_ctx); | ||
1299 | } | ||
1300 | } | ||
1301 | 1323 | ||
1324 | GNUNET_assert (channel_ctx == peer_ctx->send_channel_ctx || | ||
1325 | channel_ctx == peer_ctx->recv_channel_ctx); | ||
1302 | 1326 | ||
1303 | /** | 1327 | GNUNET_CADET_channel_destroy (channel_ctx->channel); |
1304 | * @brief Schedule the destruction of the given peer. | 1328 | remove_channel_ctx (peer_ctx->send_channel_ctx); |
1305 | * | ||
1306 | * Do so only if it was not already scheduled and not during shutdown. | ||
1307 | * | ||
1308 | * @param peer_ctx The context of the peer to destroy. | ||
1309 | */ | ||
1310 | static void | ||
1311 | schedule_peer_destruction (struct PeerContext *peer_ctx) | ||
1312 | { | ||
1313 | GNUNET_assert (NULL != peer_ctx); | ||
1314 | if (NULL != peer_ctx->destruction_task && | ||
1315 | GNUNET_NO == in_shutdown) | ||
1316 | { | ||
1317 | peer_ctx->destruction_task = | ||
1318 | GNUNET_SCHEDULER_add_now (&destroy_peer, | ||
1319 | peer_ctx); | ||
1320 | } | ||
1321 | } | 1329 | } |
1322 | 1330 | ||
1323 | 1331 | ||
@@ -1389,35 +1397,17 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1389 | 1397 | ||
1390 | /* Do we still have to wait for destruction of channels | 1398 | /* Do we still have to wait for destruction of channels |
1391 | * or issue the destruction? */ | 1399 | * or issue the destruction? */ |
1392 | if (NULL != peer_ctx->send_channel_ctx && | 1400 | if (NULL != peer_ctx->send_channel_ctx) |
1393 | NULL != peer_ctx->send_channel_ctx->destruction_task) | ||
1394 | { | ||
1395 | schedule_peer_destruction (peer_ctx); | ||
1396 | return GNUNET_NO; | ||
1397 | } | ||
1398 | if (NULL != peer_ctx->recv_channel_ctx && | ||
1399 | NULL != peer_ctx->recv_channel_ctx->destruction_task) | ||
1400 | { | 1401 | { |
1401 | schedule_peer_destruction (peer_ctx); | 1402 | destroy_channel (peer_ctx->send_channel_ctx); |
1402 | return GNUNET_NO; | 1403 | return GNUNET_NO; |
1403 | } | 1404 | } |
1404 | if (NULL != peer_ctx->recv_channel_ctx) | 1405 | if (NULL != peer_ctx->recv_channel_ctx) |
1405 | { | 1406 | { |
1406 | schedule_channel_destruction (peer_ctx->recv_channel_ctx); | 1407 | destroy_channel (peer_ctx->recv_channel_ctx); |
1407 | schedule_peer_destruction (peer_ctx); | ||
1408 | return GNUNET_NO; | ||
1409 | } | ||
1410 | if (NULL != peer_ctx->send_channel_ctx) | ||
1411 | { | ||
1412 | schedule_channel_destruction (peer_ctx->send_channel_ctx); | ||
1413 | schedule_peer_destruction (peer_ctx); | ||
1414 | return GNUNET_NO; | 1408 | return GNUNET_NO; |
1415 | } | 1409 | } |
1416 | 1410 | destroy_peer (peer_ctx); | |
1417 | if (NULL != peer_ctx->destruction_task) | ||
1418 | { | ||
1419 | GNUNET_SCHEDULER_cancel (peer_ctx->destruction_task); | ||
1420 | } | ||
1421 | 1411 | ||
1422 | if (GNUNET_YES != | 1412 | if (GNUNET_YES != |
1423 | GNUNET_CONTAINER_multipeermap_remove_all (peer_map, | 1413 | GNUNET_CONTAINER_multipeermap_remove_all (peer_map, |
@@ -1432,38 +1422,6 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1432 | 1422 | ||
1433 | 1423 | ||
1434 | /** | 1424 | /** |
1435 | * @brief set flags on a given peer. | ||
1436 | * | ||
1437 | * @param peer the peer to set flags on | ||
1438 | * @param flags the flags | ||
1439 | */ | ||
1440 | void | ||
1441 | Peers_set_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags) | ||
1442 | { | ||
1443 | struct PeerContext *peer_ctx; | ||
1444 | |||
1445 | peer_ctx = get_peer_ctx (peer); | ||
1446 | set_peer_flag (peer_ctx, flags); | ||
1447 | } | ||
1448 | |||
1449 | |||
1450 | /** | ||
1451 | * @brief unset flags on a given peer. | ||
1452 | * | ||
1453 | * @param peer the peer to unset flags on | ||
1454 | * @param flags the flags | ||
1455 | */ | ||
1456 | void | ||
1457 | Peers_unset_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags) | ||
1458 | { | ||
1459 | struct PeerContext *peer_ctx; | ||
1460 | |||
1461 | peer_ctx = get_peer_ctx (peer); | ||
1462 | unset_peer_flag (peer_ctx, flags); | ||
1463 | } | ||
1464 | |||
1465 | |||
1466 | /** | ||
1467 | * @brief Check whether flags on a peer are set. | 1425 | * @brief Check whether flags on a peer are set. |
1468 | * | 1426 | * |
1469 | * @param peer the peer to check the flag of | 1427 | * @param peer the peer to check the flag of |
@@ -1473,7 +1431,7 @@ Peers_unset_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFl | |||
1473 | * #GNUNET_YES if all given flags are set | 1431 | * #GNUNET_YES if all given flags are set |
1474 | * #GNUNET_NO otherwise | 1432 | * #GNUNET_NO otherwise |
1475 | */ | 1433 | */ |
1476 | int | 1434 | static int |
1477 | Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags) | 1435 | Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags) |
1478 | { | 1436 | { |
1479 | struct PeerContext *peer_ctx; | 1437 | struct PeerContext *peer_ctx; |
@@ -1486,28 +1444,6 @@ Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFl | |||
1486 | return check_peer_flag_set (peer_ctx, flags); | 1444 | return check_peer_flag_set (peer_ctx, flags); |
1487 | } | 1445 | } |
1488 | 1446 | ||
1489 | /** | ||
1490 | * @brief Check whether we have information about the given peer. | ||
1491 | * | ||
1492 | * FIXME probably deprecated. Make this the new _online. | ||
1493 | * | ||
1494 | * @param peer peer in question | ||
1495 | * | ||
1496 | * @return #GNUNET_YES if peer is known | ||
1497 | * #GNUNET_NO if peer is not knwon | ||
1498 | */ | ||
1499 | int | ||
1500 | Peers_check_peer_known (const struct GNUNET_PeerIdentity *peer) | ||
1501 | { | ||
1502 | if (NULL != peer_map) | ||
1503 | { | ||
1504 | return GNUNET_CONTAINER_multipeermap_contains (peer_map, peer); | ||
1505 | } else | ||
1506 | { | ||
1507 | return GNUNET_NO; | ||
1508 | } | ||
1509 | } | ||
1510 | |||
1511 | 1447 | ||
1512 | /** | 1448 | /** |
1513 | * @brief Check whether @a peer is actually a peer. | 1449 | * @brief Check whether @a peer is actually a peer. |
@@ -1519,7 +1455,7 @@ Peers_check_peer_known (const struct GNUNET_PeerIdentity *peer) | |||
1519 | * @return #GNUNET_YES if peer is valid | 1455 | * @return #GNUNET_YES if peer is valid |
1520 | * #GNUNET_NO if peer is not valid | 1456 | * #GNUNET_NO if peer is not valid |
1521 | */ | 1457 | */ |
1522 | int | 1458 | static int |
1523 | Peers_check_peer_valid (const struct GNUNET_PeerIdentity *peer) | 1459 | Peers_check_peer_valid (const struct GNUNET_PeerIdentity *peer) |
1524 | { | 1460 | { |
1525 | return GNUNET_CONTAINER_multipeermap_contains (valid_peers, peer); | 1461 | return GNUNET_CONTAINER_multipeermap_contains (valid_peers, peer); |
@@ -1533,7 +1469,7 @@ Peers_check_peer_valid (const struct GNUNET_PeerIdentity *peer) | |||
1533 | * | 1469 | * |
1534 | * @param peer the peer to establish channel to | 1470 | * @param peer the peer to establish channel to |
1535 | */ | 1471 | */ |
1536 | void | 1472 | static void |
1537 | Peers_indicate_sending_intention (const struct GNUNET_PeerIdentity *peer) | 1473 | Peers_indicate_sending_intention (const struct GNUNET_PeerIdentity *peer) |
1538 | { | 1474 | { |
1539 | GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer)); | 1475 | GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer)); |
@@ -1702,7 +1638,7 @@ Peers_destroy_sending_channel (const struct GNUNET_PeerIdentity *peer) | |||
1702 | peer_ctx = get_peer_ctx (peer); | 1638 | peer_ctx = get_peer_ctx (peer); |
1703 | if (NULL != peer_ctx->send_channel_ctx) | 1639 | if (NULL != peer_ctx->send_channel_ctx) |
1704 | { | 1640 | { |
1705 | schedule_channel_destruction (peer_ctx->send_channel_ctx); | 1641 | destroy_channel (peer_ctx->send_channel_ctx); |
1706 | (void) Peers_check_connected (peer); | 1642 | (void) Peers_check_connected (peer); |
1707 | return GNUNET_YES; | 1643 | return GNUNET_YES; |
1708 | } | 1644 | } |
@@ -1710,26 +1646,6 @@ Peers_destroy_sending_channel (const struct GNUNET_PeerIdentity *peer) | |||
1710 | } | 1646 | } |
1711 | 1647 | ||
1712 | /** | 1648 | /** |
1713 | * @brief Callback for scheduler to destroy a channel | ||
1714 | * | ||
1715 | * @param cls Context of the channel | ||
1716 | */ | ||
1717 | static void | ||
1718 | destroy_channel (void *cls) | ||
1719 | { | ||
1720 | struct ChannelCtx *channel_ctx = cls; | ||
1721 | struct PeerContext *peer_ctx = channel_ctx->peer_ctx; | ||
1722 | |||
1723 | GNUNET_assert (channel_ctx == peer_ctx->send_channel_ctx || | ||
1724 | channel_ctx == peer_ctx->recv_channel_ctx); | ||
1725 | |||
1726 | channel_ctx->destruction_task = NULL; | ||
1727 | GNUNET_CADET_channel_destroy (channel_ctx->channel); | ||
1728 | remove_channel_ctx (peer_ctx->send_channel_ctx); | ||
1729 | } | ||
1730 | |||
1731 | |||
1732 | /** | ||
1733 | * @brief Send a message to another peer. | 1649 | * @brief Send a message to another peer. |
1734 | * | 1650 | * |
1735 | * Keeps track about pending messages so they can be properly removed when the | 1651 | * Keeps track about pending messages so they can be properly removed when the |
@@ -2605,7 +2521,7 @@ remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
2605 | CustomPeerMap_remove_peer (push_map, peer); | 2521 | CustomPeerMap_remove_peer (push_map, peer); |
2606 | RPS_sampler_reinitialise_by_value (prot_sampler, peer); | 2522 | RPS_sampler_reinitialise_by_value (prot_sampler, peer); |
2607 | RPS_sampler_reinitialise_by_value (client_sampler, peer); | 2523 | RPS_sampler_reinitialise_by_value (client_sampler, peer); |
2608 | schedule_peer_destruction (get_peer_ctx (peer)); | 2524 | destroy_peer (get_peer_ctx (peer)); |
2609 | } | 2525 | } |
2610 | 2526 | ||
2611 | 2527 | ||
@@ -2675,10 +2591,6 @@ remove_channel_ctx (struct ChannelCtx *channel_ctx) | |||
2675 | { | 2591 | { |
2676 | struct PeerContext *peer_ctx = channel_ctx->peer_ctx; | 2592 | struct PeerContext *peer_ctx = channel_ctx->peer_ctx; |
2677 | 2593 | ||
2678 | if (NULL != channel_ctx->destruction_task) | ||
2679 | { | ||
2680 | GNUNET_SCHEDULER_cancel (channel_ctx->destruction_task); | ||
2681 | } | ||
2682 | GNUNET_free (channel_ctx); | 2594 | GNUNET_free (channel_ctx); |
2683 | if (channel_ctx == peer_ctx->send_channel_ctx) | 2595 | if (channel_ctx == peer_ctx->send_channel_ctx) |
2684 | { | 2596 | { |
@@ -4098,7 +4010,7 @@ shutdown_task (void *cls) | |||
4098 | do_round_task = NULL; | 4010 | do_round_task = NULL; |
4099 | } | 4011 | } |
4100 | 4012 | ||
4101 | Peers_terminate (); | 4013 | peers_terminate (); |
4102 | 4014 | ||
4103 | GNUNET_NSE_disconnect (nse); | 4015 | GNUNET_NSE_disconnect (nse); |
4104 | RPS_sampler_destroy (prot_sampler); | 4016 | RPS_sampler_destroy (prot_sampler); |
diff --git a/src/rps/gnunet-service-rps_custommap.c b/src/rps/gnunet-service-rps_custommap.c index 9e003eb39..3513ff8da 100644 --- a/src/rps/gnunet-service-rps_custommap.c +++ b/src/rps/gnunet-service-rps_custommap.c | |||
@@ -202,6 +202,7 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map, | |||
202 | p = GNUNET_CONTAINER_multihashmap32_get (c_peer_map->hash_map, *index); | 202 | p = GNUNET_CONTAINER_multihashmap32_get (c_peer_map->hash_map, *index); |
203 | GNUNET_assert (NULL != p); | 203 | GNUNET_assert (NULL != p); |
204 | GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map, *index); | 204 | GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map, *index); |
205 | // TODO wrong peerid? | ||
205 | GNUNET_CONTAINER_multipeermap_remove_all (c_peer_map->peer_map, peer); | 206 | GNUNET_CONTAINER_multipeermap_remove_all (c_peer_map->peer_map, peer); |
206 | if (*index != CustomPeerMap_size (c_peer_map)) | 207 | if (*index != CustomPeerMap_size (c_peer_map)) |
207 | { /* fill 'gap' with peer at last index */ | 208 | { /* fill 'gap' with peer at last index */ |
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c index 08fe96097..ed682c251 100644 --- a/src/rps/rps-test_util.c +++ b/src/rps/rps-test_util.c | |||
@@ -239,7 +239,7 @@ to_file_raw_unaligned (const char *file_name, | |||
239 | /* needed bits of the input byte that have not been moved */ | 239 | /* needed bits of the input byte that have not been moved */ |
240 | char byte_input_leftover; | 240 | char byte_input_leftover; |
241 | unsigned num_bits_leftover; | 241 | unsigned num_bits_leftover; |
242 | unsigned num_bits_discard; | 242 | //unsigned num_bits_discard; |
243 | char byte_unaligned_new; | 243 | char byte_unaligned_new; |
244 | 244 | ||
245 | if ( (bits_needed - (i * 8)) <= 8) | 245 | if ( (bits_needed - (i * 8)) <= 8) |
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 08424022f..92d8c12ea 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -2850,7 +2850,7 @@ main (int argc, char *argv[]) | |||
2850 | { | 2850 | { |
2851 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n"); | 2851 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n"); |
2852 | cur_test_run.name = "test-rps-profiler"; | 2852 | cur_test_run.name = "test-rps-profiler"; |
2853 | num_peers = 100; | 2853 | num_peers = 16; |
2854 | mal_type = 3; | 2854 | mal_type = 3; |
2855 | cur_test_run.init_peer = profiler_init_peer; | 2855 | cur_test_run.init_peer = profiler_init_peer; |
2856 | //cur_test_run.pre_test = mal_pre; | 2856 | //cur_test_run.pre_test = mal_pre; |
diff --git a/src/rps/test_rps.conf b/src/rps/test_rps.conf index 05bb9f444..02fbf76a4 100644 --- a/src/rps/test_rps.conf +++ b/src/rps/test_rps.conf | |||
@@ -1,5 +1,6 @@ | |||
1 | [rps] | 1 | [rps] |
2 | #PREFIX = valgrind --leak-check=full --show-leak-kinds=all --log-file=/tmp/rps/valgrind!gnunet-service-rps!%p | 2 | #PREFIX = valgrind --leak-check=full --show-leak-kinds=all --log-file=/tmp/rps/valgrind!gnunet-service-rps!%p |
3 | #PREFIX = valgrind --log-file=/tmp/rps/valgrind!gnunet-service-rps!%p | ||
3 | #BINARY = gnunet-service-rps | 4 | #BINARY = gnunet-service-rps |
4 | UNIXPATH = $GNUNET_TMP/gnunet-service-rps.sock | 5 | UNIXPATH = $GNUNET_TMP/gnunet-service-rps.sock |
5 | HOME = $SERVICEHOME | 6 | HOME = $SERVICEHOME |