diff options
Diffstat (limited to 'src/rps')
-rw-r--r-- | src/rps/gnunet-rps.c | 15 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps.c | 160 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps_sampler.c | 14 | ||||
-rw-r--r-- | src/rps/test_rps.c | 16 |
4 files changed, 90 insertions, 115 deletions
diff --git a/src/rps/gnunet-rps.c b/src/rps/gnunet-rps.c index 01be2aeb3..705c2c9b0 100644 --- a/src/rps/gnunet-rps.c +++ b/src/rps/gnunet-rps.c | |||
@@ -46,12 +46,6 @@ static struct GNUNET_PeerIdentity *peer_id; | |||
46 | 46 | ||
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Shutdown task | ||
50 | */ | ||
51 | static struct GNUNET_SCHEDULER_Task *shutdown_task; | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Set an option of type 'struct GNUNET_PeerIdentity *' from the command line. | 49 | * Set an option of type 'struct GNUNET_PeerIdentity *' from the command line. |
56 | * A pointer to this function should be passed as part of the | 50 | * A pointer to this function should be passed as part of the |
57 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options | 51 | * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options |
@@ -96,7 +90,6 @@ GNUNET_GETOPT_set_peerid (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, | |||
96 | static void | 90 | static void |
97 | do_shutdown (void *cls) | 91 | do_shutdown (void *cls) |
98 | { | 92 | { |
99 | shutdown_task = NULL; | ||
100 | if (NULL != req_handle) | 93 | if (NULL != req_handle) |
101 | GNUNET_RPS_request_cancel (req_handle); | 94 | GNUNET_RPS_request_cancel (req_handle); |
102 | GNUNET_RPS_disconnect (rps_handle); | 95 | GNUNET_RPS_disconnect (rps_handle); |
@@ -126,8 +119,7 @@ reply_handle (void *cls, | |||
126 | } | 119 | } |
127 | ret = 0; | 120 | ret = 0; |
128 | 121 | ||
129 | GNUNET_SCHEDULER_cancel (shutdown_task); | 122 | GNUNET_SCHEDULER_shutdown (); |
130 | GNUNET_SCHEDULER_add_now (do_shutdown, NULL); | ||
131 | } | 123 | } |
132 | 124 | ||
133 | 125 | ||
@@ -156,15 +148,14 @@ run (void *cls, | |||
156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 148 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
157 | "Requesting %u PeerIDs\n", num_peers); | 149 | "Requesting %u PeerIDs\n", num_peers); |
158 | req_handle = GNUNET_RPS_request_peers (rps_handle, num_peers, reply_handle, NULL); | 150 | req_handle = GNUNET_RPS_request_peers (rps_handle, num_peers, reply_handle, NULL); |
159 | shutdown_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 151 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); |
160 | &do_shutdown, NULL); | ||
161 | } | 152 | } |
162 | else | 153 | else |
163 | { /* Seed PeerID */ | 154 | { /* Seed PeerID */ |
164 | GNUNET_RPS_seed_ids (rps_handle, 1, peer_id); | 155 | GNUNET_RPS_seed_ids (rps_handle, 1, peer_id); |
165 | FPRINTF (stdout, "Seeded PeerID %s\n", GNUNET_i2s_full (peer_id)); | 156 | FPRINTF (stdout, "Seeded PeerID %s\n", GNUNET_i2s_full (peer_id)); |
166 | ret = 0; | 157 | ret = 0; |
167 | GNUNET_SCHEDULER_add_now (do_shutdown, NULL); | 158 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
168 | } | 159 | } |
169 | } | 160 | } |
170 | 161 | ||
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index af06cf1bd..91d4840bb 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) | 3 | Copyright (C) 2013-2015 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 |
@@ -149,16 +149,14 @@ static struct RPS_Sampler *prot_sampler; | |||
149 | */ | 149 | */ |
150 | static struct RPS_Sampler *client_sampler; | 150 | static struct RPS_Sampler *client_sampler; |
151 | 151 | ||
152 | |||
153 | /** | 152 | /** |
154 | * Name to log view to | 153 | * Name to log view to |
155 | */ | 154 | */ |
156 | static char *file_name_view_log; | 155 | static char *file_name_view_log; |
157 | 156 | ||
158 | |||
159 | /** | 157 | /** |
160 | * The size of sampler we need to be able to satisfy the client's need of | 158 | * The size of sampler we need to be able to satisfy the client's need |
161 | * random peers. | 159 | * of random peers. |
162 | */ | 160 | */ |
163 | static unsigned int sampler_size_client_need; | 161 | static unsigned int sampler_size_client_need; |
164 | 162 | ||
@@ -170,7 +168,6 @@ static unsigned int sampler_size_client_need; | |||
170 | */ | 168 | */ |
171 | static unsigned int sampler_size_est_need; | 169 | static unsigned int sampler_size_est_need; |
172 | 170 | ||
173 | |||
174 | /** | 171 | /** |
175 | * Percentage of total peer number in the view | 172 | * Percentage of total peer number in the view |
176 | * to send random PUSHes to | 173 | * to send random PUSHes to |
@@ -184,12 +181,6 @@ static float alpha; | |||
184 | static float beta; | 181 | static float beta; |
185 | 182 | ||
186 | /** | 183 | /** |
187 | * The percentage gamma of history updates. | ||
188 | * Simply 1 - alpha - beta | ||
189 | */ | ||
190 | |||
191 | |||
192 | /** | ||
193 | * Identifier for the main task that runs periodically. | 184 | * Identifier for the main task that runs periodically. |
194 | */ | 185 | */ |
195 | static struct GNUNET_SCHEDULER_Task *do_round_task; | 186 | static struct GNUNET_SCHEDULER_Task *do_round_task; |
@@ -199,8 +190,6 @@ static struct GNUNET_SCHEDULER_Task *do_round_task; | |||
199 | */ | 190 | */ |
200 | static struct GNUNET_TIME_Relative round_interval; | 191 | static struct GNUNET_TIME_Relative round_interval; |
201 | 192 | ||
202 | |||
203 | |||
204 | /** | 193 | /** |
205 | * List to store peers received through pushes temporary. | 194 | * List to store peers received through pushes temporary. |
206 | */ | 195 | */ |
@@ -211,7 +200,6 @@ static struct CustomPeerMap *push_map; | |||
211 | */ | 200 | */ |
212 | static struct CustomPeerMap *pull_map; | 201 | static struct CustomPeerMap *pull_map; |
213 | 202 | ||
214 | |||
215 | /** | 203 | /** |
216 | * Handler to NSE. | 204 | * Handler to NSE. |
217 | */ | 205 | */ |
@@ -230,8 +218,7 @@ static struct GNUNET_PEERINFO_Handle *peerinfo_handle; | |||
230 | /** | 218 | /** |
231 | * Handle for cancellation of iteration over peers. | 219 | * Handle for cancellation of iteration over peers. |
232 | */ | 220 | */ |
233 | struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle; | 221 | static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle; |
234 | |||
235 | 222 | ||
236 | /** | 223 | /** |
237 | * Request counter. | 224 | * Request counter. |
@@ -263,13 +250,12 @@ static struct GNUNET_TIME_Relative request_deltas[REQUEST_DELTAS_SIZE]; | |||
263 | /** | 250 | /** |
264 | * The prediction of the rate of requests | 251 | * The prediction of the rate of requests |
265 | */ | 252 | */ |
266 | static struct GNUNET_TIME_Relative request_rate; | 253 | static struct GNUNET_TIME_Relative request_rate; |
267 | |||
268 | 254 | ||
269 | /** | 255 | /** |
270 | * Number of history update tasks. | 256 | * Number of history update tasks. |
271 | */ | 257 | */ |
272 | uint32_t num_hist_update_tasks; | 258 | static uint32_t num_hist_update_tasks; |
273 | 259 | ||
274 | 260 | ||
275 | #ifdef ENABLE_MALICIOUS | 261 | #ifdef ENABLE_MALICIOUS |
@@ -281,18 +267,18 @@ uint32_t num_hist_update_tasks; | |||
281 | * 2 Try to partition the network | 267 | * 2 Try to partition the network |
282 | * 3 Combined attack | 268 | * 3 Combined attack |
283 | */ | 269 | */ |
284 | uint32_t mal_type = 0; | 270 | static uint32_t mal_type; |
285 | 271 | ||
286 | /** | 272 | /** |
287 | * Other malicious peers | 273 | * Other malicious peers |
288 | */ | 274 | */ |
289 | static struct GNUNET_PeerIdentity *mal_peers = NULL; | 275 | static struct GNUNET_PeerIdentity *mal_peers; |
290 | 276 | ||
291 | /** | 277 | /** |
292 | * Hashmap of malicious peers used as set. | 278 | * Hashmap of malicious peers used as set. |
293 | * Used to more efficiently check whether we know that peer. | 279 | * Used to more efficiently check whether we know that peer. |
294 | */ | 280 | */ |
295 | static struct GNUNET_CONTAINER_MultiPeerMap *mal_peer_set = NULL; | 281 | static struct GNUNET_CONTAINER_MultiPeerMap *mal_peer_set; |
296 | 282 | ||
297 | /** | 283 | /** |
298 | * Number of other malicious peers | 284 | * Number of other malicious peers |
@@ -320,26 +306,25 @@ struct AttackedPeer | |||
320 | /** | 306 | /** |
321 | * If type is 2 this is the DLL of attacked peers | 307 | * If type is 2 this is the DLL of attacked peers |
322 | */ | 308 | */ |
323 | static struct AttackedPeer *att_peers_head = NULL; | 309 | static struct AttackedPeer *att_peers_head; |
324 | static struct AttackedPeer *att_peers_tail = NULL; | 310 | static struct AttackedPeer *att_peers_tail; |
325 | 311 | ||
326 | /** | 312 | /** |
327 | * This index is used to point to an attacked peer to | 313 | * This index is used to point to an attacked peer to |
328 | * implement the round-robin-ish way to select attacked peers. | 314 | * implement the round-robin-ish way to select attacked peers. |
329 | */ | 315 | */ |
330 | static struct AttackedPeer *att_peer_index = NULL; | 316 | static struct AttackedPeer *att_peer_index; |
331 | 317 | ||
332 | /** | 318 | /** |
333 | * Hashmap of attacked peers used as set. | 319 | * Hashmap of attacked peers used as set. |
334 | * Used to more efficiently check whether we know that peer. | 320 | * Used to more efficiently check whether we know that peer. |
335 | */ | 321 | */ |
336 | static struct GNUNET_CONTAINER_MultiPeerMap *att_peer_set = NULL; | 322 | static struct GNUNET_CONTAINER_MultiPeerMap *att_peer_set; |
337 | 323 | ||
338 | /** | 324 | /** |
339 | * Number of attacked peers | 325 | * Number of attacked peers |
340 | */ | 326 | */ |
341 | static uint32_t num_attacked_peers = 0; | 327 | static uint32_t num_attacked_peers; |
342 | |||
343 | 328 | ||
344 | /** | 329 | /** |
345 | * If type is 1 this is the attacked peer | 330 | * If type is 1 this is the attacked peer |
@@ -362,10 +347,6 @@ static uint32_t push_limit = 10000; | |||
362 | ***********************************************************************/ | 347 | ***********************************************************************/ |
363 | 348 | ||
364 | 349 | ||
365 | |||
366 | |||
367 | |||
368 | |||
369 | /*********************************************************************** | 350 | /*********************************************************************** |
370 | * Util functions | 351 | * Util functions |
371 | ***********************************************************************/ | 352 | ***********************************************************************/ |
@@ -374,8 +355,9 @@ static uint32_t push_limit = 10000; | |||
374 | /** | 355 | /** |
375 | * Print peerlist to log. | 356 | * Print peerlist to log. |
376 | */ | 357 | */ |
377 | void | 358 | static void |
378 | print_peer_list (struct GNUNET_PeerIdentity *list, unsigned int len) | 359 | print_peer_list (struct GNUNET_PeerIdentity *list, |
360 | unsigned int len) | ||
379 | { | 361 | { |
380 | unsigned int i; | 362 | unsigned int i; |
381 | 363 | ||
@@ -395,7 +377,7 @@ print_peer_list (struct GNUNET_PeerIdentity *list, unsigned int len) | |||
395 | /** | 377 | /** |
396 | * Remove peer from list. | 378 | * Remove peer from list. |
397 | */ | 379 | */ |
398 | void | 380 | static void |
399 | rem_from_list (struct GNUNET_PeerIdentity **peer_list, | 381 | rem_from_list (struct GNUNET_PeerIdentity **peer_list, |
400 | unsigned int *list_size, | 382 | unsigned int *list_size, |
401 | const struct GNUNET_PeerIdentity *peer) | 383 | const struct GNUNET_PeerIdentity *peer) |
@@ -429,9 +411,10 @@ rem_from_list (struct GNUNET_PeerIdentity **peer_list, | |||
429 | 411 | ||
430 | /** | 412 | /** |
431 | * Sum all time relatives of an array. | 413 | * Sum all time relatives of an array. |
432 | */ | 414 | */ |
433 | struct GNUNET_TIME_Relative | 415 | static struct GNUNET_TIME_Relative |
434 | T_relative_sum (const struct GNUNET_TIME_Relative *rel_array, uint32_t arr_size) | 416 | T_relative_sum (const struct GNUNET_TIME_Relative *rel_array, |
417 | uint32_t arr_size) | ||
435 | { | 418 | { |
436 | struct GNUNET_TIME_Relative sum; | 419 | struct GNUNET_TIME_Relative sum; |
437 | uint32_t i; | 420 | uint32_t i; |
@@ -448,18 +431,23 @@ T_relative_sum (const struct GNUNET_TIME_Relative *rel_array, uint32_t arr_size) | |||
448 | /** | 431 | /** |
449 | * Compute the average of given time relatives. | 432 | * Compute the average of given time relatives. |
450 | */ | 433 | */ |
451 | struct GNUNET_TIME_Relative | 434 | static struct GNUNET_TIME_Relative |
452 | T_relative_avg (const struct GNUNET_TIME_Relative *rel_array, uint32_t arr_size) | 435 | T_relative_avg (const struct GNUNET_TIME_Relative *rel_array, |
436 | uint32_t arr_size) | ||
453 | { | 437 | { |
454 | return GNUNET_TIME_relative_divide (T_relative_sum (rel_array, arr_size), arr_size); | 438 | return GNUNET_TIME_relative_divide (T_relative_sum (rel_array, |
439 | arr_size), | ||
440 | arr_size); | ||
455 | } | 441 | } |
456 | 442 | ||
457 | 443 | ||
458 | /** | 444 | /** |
459 | * Put random peer from sampler into the view as history update. | 445 | * Put random peer from sampler into the view as history update. |
460 | */ | 446 | */ |
461 | void | 447 | static void |
462 | hist_update (void *cls, struct GNUNET_PeerIdentity *ids, uint32_t num_peers) | 448 | hist_update (void *cls, |
449 | struct GNUNET_PeerIdentity *ids, | ||
450 | uint32_t num_peers) | ||
463 | { | 451 | { |
464 | unsigned int i; | 452 | unsigned int i; |
465 | 453 | ||
@@ -475,7 +463,6 @@ hist_update (void *cls, struct GNUNET_PeerIdentity *ids, uint32_t num_peers) | |||
475 | } | 463 | } |
476 | 464 | ||
477 | 465 | ||
478 | |||
479 | /** | 466 | /** |
480 | * Wrapper around #RPS_sampler_resize() | 467 | * Wrapper around #RPS_sampler_resize() |
481 | * | 468 | * |
@@ -526,7 +513,7 @@ client_resize_wrapper () | |||
526 | * | 513 | * |
527 | * Called every time we receive a request from the client. | 514 | * Called every time we receive a request from the client. |
528 | */ | 515 | */ |
529 | void | 516 | static void |
530 | est_request_rate() | 517 | est_request_rate() |
531 | { | 518 | { |
532 | struct GNUNET_TIME_Relative max_round_duration; | 519 | struct GNUNET_TIME_Relative max_round_duration; |
@@ -647,28 +634,33 @@ send_pull_reply (const struct GNUNET_PeerIdentity *peer_id, | |||
647 | * | 634 | * |
648 | * Called once we know a peer is live. | 635 | * Called once we know a peer is live. |
649 | */ | 636 | */ |
650 | void | 637 | static void |
651 | insert_in_pull_map (void *cls, const struct GNUNET_PeerIdentity *peer) | 638 | insert_in_pull_map (void *cls, |
639 | const struct GNUNET_PeerIdentity *peer) | ||
652 | { | 640 | { |
653 | CustomPeerMap_put (pull_map, peer); | 641 | CustomPeerMap_put (pull_map, peer); |
654 | } | 642 | } |
655 | 643 | ||
644 | |||
656 | /** | 645 | /** |
657 | * Insert PeerID in #view | 646 | * Insert PeerID in #view |
658 | * | 647 | * |
659 | * Called once we know a peer is live. | 648 | * Called once we know a peer is live. |
660 | */ | 649 | */ |
661 | void | 650 | static void |
662 | insert_in_view (void *cls, const struct GNUNET_PeerIdentity *peer) | 651 | insert_in_view (void *cls, |
652 | const struct GNUNET_PeerIdentity *peer) | ||
663 | { | 653 | { |
664 | View_put (peer); | 654 | View_put (peer); |
665 | } | 655 | } |
666 | 656 | ||
657 | |||
667 | /** | 658 | /** |
668 | * Update sampler with given PeerID. | 659 | * Update sampler with given PeerID. |
669 | */ | 660 | */ |
670 | void | 661 | static void |
671 | insert_in_sampler (void *cls, const struct GNUNET_PeerIdentity *peer) | 662 | insert_in_sampler (void *cls, |
663 | const struct GNUNET_PeerIdentity *peer) | ||
672 | { | 664 | { |
673 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 665 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
674 | "Updating samplers with peer %s from insert_in_sampler()\n", | 666 | "Updating samplers with peer %s from insert_in_sampler()\n", |
@@ -875,6 +867,7 @@ destroy_reply_cls (struct ReplyCls *rep_cls) | |||
875 | GNUNET_free (rep_cls); | 867 | GNUNET_free (rep_cls); |
876 | } | 868 | } |
877 | 869 | ||
870 | |||
878 | static void | 871 | static void |
879 | destroy_cli_ctx (struct ClientContext *cli_ctx) | 872 | destroy_cli_ctx (struct ClientContext *cli_ctx) |
880 | { | 873 | { |
@@ -899,8 +892,9 @@ destroy_cli_ctx (struct ClientContext *cli_ctx) | |||
899 | * Updates sizes of sampler list and view and adapt those lists | 892 | * Updates sizes of sampler list and view and adapt those lists |
900 | * accordingly. | 893 | * accordingly. |
901 | */ | 894 | */ |
902 | void | 895 | static void |
903 | nse_callback (void *cls, struct GNUNET_TIME_Absolute timestamp, | 896 | nse_callback (void *cls, |
897 | struct GNUNET_TIME_Absolute timestamp, | ||
904 | double logestimate, double std_dev) | 898 | double logestimate, double std_dev) |
905 | { | 899 | { |
906 | double estimate; | 900 | double estimate; |
@@ -933,7 +927,7 @@ nse_callback (void *cls, struct GNUNET_TIME_Absolute timestamp, | |||
933 | * | 927 | * |
934 | * Sends those to the requesting client. | 928 | * Sends those to the requesting client. |
935 | */ | 929 | */ |
936 | void | 930 | static void |
937 | client_respond (void *cls, | 931 | client_respond (void *cls, |
938 | struct GNUNET_PeerIdentity *peer_ids, | 932 | struct GNUNET_PeerIdentity *peer_ids, |
939 | uint32_t num_peers) | 933 | uint32_t num_peers) |
@@ -1080,7 +1074,7 @@ handle_client_request_cancel (void *cls, | |||
1080 | * @param client identification of the client | 1074 | * @param client identification of the client |
1081 | * @param message the actual message | 1075 | * @param message the actual message |
1082 | */ | 1076 | */ |
1083 | static void | 1077 | static void |
1084 | handle_client_seed (void *cls, | 1078 | handle_client_seed (void *cls, |
1085 | struct GNUNET_SERVER_Client *client, | 1079 | struct GNUNET_SERVER_Client *client, |
1086 | const struct GNUNET_MessageHeader *message) | 1080 | const struct GNUNET_MessageHeader *message) |
@@ -1136,7 +1130,7 @@ handle_client_seed (void *cls, | |||
1136 | ////GNUNET_free (peers); | 1130 | ////GNUNET_free (peers); |
1137 | 1131 | ||
1138 | GNUNET_SERVER_receive_done (client, | 1132 | GNUNET_SERVER_receive_done (client, |
1139 | GNUNET_OK); | 1133 | GNUNET_OK); |
1140 | } | 1134 | } |
1141 | 1135 | ||
1142 | 1136 | ||
@@ -1153,9 +1147,9 @@ handle_client_seed (void *cls, | |||
1153 | */ | 1147 | */ |
1154 | static int | 1148 | static int |
1155 | handle_peer_push (void *cls, | 1149 | handle_peer_push (void *cls, |
1156 | struct GNUNET_CADET_Channel *channel, | 1150 | struct GNUNET_CADET_Channel *channel, |
1157 | void **channel_ctx, | 1151 | void **channel_ctx, |
1158 | const struct GNUNET_MessageHeader *msg) | 1152 | const struct GNUNET_MessageHeader *msg) |
1159 | { | 1153 | { |
1160 | const struct GNUNET_PeerIdentity *peer; | 1154 | const struct GNUNET_PeerIdentity *peer; |
1161 | 1155 | ||
@@ -1165,9 +1159,11 @@ handle_peer_push (void *cls, | |||
1165 | GNUNET_CADET_channel_get_info (channel, GNUNET_CADET_OPTION_PEER); | 1159 | GNUNET_CADET_channel_get_info (channel, GNUNET_CADET_OPTION_PEER); |
1166 | // FIXME wait for cadet to change this function | 1160 | // FIXME wait for cadet to change this function |
1167 | 1161 | ||
1168 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PUSH (%s)\n", GNUNET_i2s (peer)); | 1162 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1163 | "Received PUSH (%s)\n", | ||
1164 | GNUNET_i2s (peer)); | ||
1169 | 1165 | ||
1170 | #ifdef ENABLE_MALICIOUS | 1166 | #ifdef ENABLE_MALICIOUS |
1171 | struct AttackedPeer *tmp_att_peer; | 1167 | struct AttackedPeer *tmp_att_peer; |
1172 | 1168 | ||
1173 | tmp_att_peer = GNUNET_new (struct AttackedPeer); | 1169 | tmp_att_peer = GNUNET_new (struct AttackedPeer); |
@@ -1220,9 +1216,9 @@ handle_peer_push (void *cls, | |||
1220 | */ | 1216 | */ |
1221 | static int | 1217 | static int |
1222 | handle_peer_pull_request (void *cls, | 1218 | handle_peer_pull_request (void *cls, |
1223 | struct GNUNET_CADET_Channel *channel, | 1219 | struct GNUNET_CADET_Channel *channel, |
1224 | void **channel_ctx, | 1220 | void **channel_ctx, |
1225 | const struct GNUNET_MessageHeader *msg) | 1221 | const struct GNUNET_MessageHeader *msg) |
1226 | { | 1222 | { |
1227 | struct GNUNET_PeerIdentity *peer; | 1223 | struct GNUNET_PeerIdentity *peer; |
1228 | const struct GNUNET_PeerIdentity *view_array; | 1224 | const struct GNUNET_PeerIdentity *view_array; |
@@ -1272,7 +1268,7 @@ handle_peer_pull_request (void *cls, | |||
1272 | * @param channel_ctx The context associated with this channel | 1268 | * @param channel_ctx The context associated with this channel |
1273 | * @param msg The message header | 1269 | * @param msg The message header |
1274 | */ | 1270 | */ |
1275 | static int | 1271 | static int |
1276 | handle_peer_pull_reply (void *cls, | 1272 | handle_peer_pull_reply (void *cls, |
1277 | struct GNUNET_CADET_Channel *channel, | 1273 | struct GNUNET_CADET_Channel *channel, |
1278 | void **channel_ctx, | 1274 | void **channel_ctx, |
@@ -1404,7 +1400,8 @@ handle_peer_pull_reply (void *cls, | |||
1404 | * @param spread the inverse amount of deviation from the mean | 1400 | * @param spread the inverse amount of deviation from the mean |
1405 | */ | 1401 | */ |
1406 | static struct GNUNET_TIME_Relative | 1402 | static struct GNUNET_TIME_Relative |
1407 | compute_rand_delay (struct GNUNET_TIME_Relative mean, unsigned int spread) | 1403 | compute_rand_delay (struct GNUNET_TIME_Relative mean, |
1404 | unsigned int spread) | ||
1408 | { | 1405 | { |
1409 | struct GNUNET_TIME_Relative half_interval; | 1406 | struct GNUNET_TIME_Relative half_interval; |
1410 | struct GNUNET_TIME_Relative ret; | 1407 | struct GNUNET_TIME_Relative ret; |
@@ -1496,7 +1493,7 @@ do_mal_round (void *cls); | |||
1496 | * @param client The client that sent the message | 1493 | * @param client The client that sent the message |
1497 | * @param msg The message header | 1494 | * @param msg The message header |
1498 | */ | 1495 | */ |
1499 | static void | 1496 | static void |
1500 | handle_client_act_malicious (void *cls, | 1497 | handle_client_act_malicious (void *cls, |
1501 | struct GNUNET_SERVER_Client *client, | 1498 | struct GNUNET_SERVER_Client *client, |
1502 | const struct GNUNET_MessageHeader *msg) | 1499 | const struct GNUNET_MessageHeader *msg) |
@@ -1613,8 +1610,8 @@ handle_client_act_malicious (void *cls, | |||
1613 | { | 1610 | { |
1614 | GNUNET_break (0); | 1611 | GNUNET_break (0); |
1615 | } | 1612 | } |
1616 | 1613 | GNUNET_SERVER_receive_done (client, | |
1617 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1614 | GNUNET_OK); |
1618 | } | 1615 | } |
1619 | 1616 | ||
1620 | 1617 | ||
@@ -1631,7 +1628,8 @@ do_mal_round (void *cls) | |||
1631 | struct GNUNET_TIME_Relative time_next_round; | 1628 | struct GNUNET_TIME_Relative time_next_round; |
1632 | struct AttackedPeer *tmp_att_peer; | 1629 | struct AttackedPeer *tmp_att_peer; |
1633 | 1630 | ||
1634 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round maliciously type %" PRIu32 ".\n", | 1631 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1632 | "Going to execute next round maliciously type %" PRIu32 ".\n", | ||
1635 | mal_type); | 1633 | mal_type); |
1636 | do_round_task = NULL; | 1634 | do_round_task = NULL; |
1637 | GNUNET_assert (mal_type <= 3); | 1635 | GNUNET_assert (mal_type <= 3); |
@@ -1744,7 +1742,8 @@ do_mal_round (void *cls) | |||
1744 | //do_round_task = GNUNET_SCHEDULER_add_delayed (round_interval, &do_mal_round, | 1742 | //do_round_task = GNUNET_SCHEDULER_add_delayed (round_interval, &do_mal_round, |
1745 | //NULL); | 1743 | //NULL); |
1746 | GNUNET_assert (NULL == do_round_task); | 1744 | GNUNET_assert (NULL == do_round_task); |
1747 | do_round_task = GNUNET_SCHEDULER_add_delayed (time_next_round, &do_mal_round, NULL); | 1745 | do_round_task = GNUNET_SCHEDULER_add_delayed (time_next_round, |
1746 | &do_mal_round, NULL); | ||
1748 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n"); | 1747 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n"); |
1749 | } | 1748 | } |
1750 | #endif /* ENABLE_MALICIOUS */ | 1749 | #endif /* ENABLE_MALICIOUS */ |
@@ -1758,8 +1757,6 @@ do_mal_round (void *cls) | |||
1758 | static void | 1757 | static void |
1759 | do_round (void *cls) | 1758 | do_round (void *cls) |
1760 | { | 1759 | { |
1761 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round.\n"); | ||
1762 | |||
1763 | uint32_t i; | 1760 | uint32_t i; |
1764 | const struct GNUNET_PeerIdentity *view_array; | 1761 | const struct GNUNET_PeerIdentity *view_array; |
1765 | unsigned int *permut; | 1762 | unsigned int *permut; |
@@ -1770,6 +1767,8 @@ do_round (void *cls) | |||
1770 | struct GNUNET_PeerIdentity peer; | 1767 | struct GNUNET_PeerIdentity peer; |
1771 | struct GNUNET_PeerIdentity *update_peer; | 1768 | struct GNUNET_PeerIdentity *update_peer; |
1772 | 1769 | ||
1770 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1771 | "Going to execute next round.\n"); | ||
1773 | do_round_task = NULL; | 1772 | do_round_task = NULL; |
1774 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1773 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1775 | "Printing view:\n"); | 1774 | "Printing view:\n"); |
@@ -1967,7 +1966,8 @@ do_round (void *cls) | |||
1967 | time_next_round = compute_rand_delay (round_interval, 2); | 1966 | time_next_round = compute_rand_delay (round_interval, 2); |
1968 | 1967 | ||
1969 | /* Schedule next round */ | 1968 | /* Schedule next round */ |
1970 | do_round_task = GNUNET_SCHEDULER_add_delayed (time_next_round, &do_round, NULL); | 1969 | do_round_task = GNUNET_SCHEDULER_add_delayed (time_next_round, |
1970 | &do_round, NULL); | ||
1971 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n"); | 1971 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished round\n"); |
1972 | } | 1972 | } |
1973 | 1973 | ||
@@ -2036,9 +2036,8 @@ process_peerinfo_peers (void *cls, | |||
2036 | static void | 2036 | static void |
2037 | shutdown_task (void *cls) | 2037 | shutdown_task (void *cls) |
2038 | { | 2038 | { |
2039 | 2039 | LOG (GNUNET_ERROR_TYPE_DEBUG, | |
2040 | LOG (GNUNET_ERROR_TYPE_DEBUG, "RPS is going down\n"); | 2040 | "RPS is going down\n"); |
2041 | |||
2042 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle); | 2041 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle); |
2043 | GNUNET_PEERINFO_disconnect (peerinfo_handle); | 2042 | GNUNET_PEERINFO_disconnect (peerinfo_handle); |
2044 | 2043 | ||
@@ -2153,9 +2152,8 @@ rps_start (struct GNUNET_SERVER_Handle *server) | |||
2153 | do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL); | 2152 | do_round_task = GNUNET_SCHEDULER_add_now (&do_round, NULL); |
2154 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); | 2153 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Scheduled first round\n"); |
2155 | 2154 | ||
2156 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 2155 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
2157 | &shutdown_task, | 2156 | NULL); |
2158 | NULL); | ||
2159 | } | 2157 | } |
2160 | 2158 | ||
2161 | 2159 | ||
diff --git a/src/rps/gnunet-service-rps_sampler.c b/src/rps/gnunet-service-rps_sampler.c index e5f6595bb..2ac6054f4 100644 --- a/src/rps/gnunet-service-rps_sampler.c +++ b/src/rps/gnunet-service-rps_sampler.c | |||
@@ -533,12 +533,8 @@ sampler_get_rand_peer (void *cls) | |||
533 | struct GetPeerCls *gpc = cls; | 533 | struct GetPeerCls *gpc = cls; |
534 | uint32_t r_index; | 534 | uint32_t r_index; |
535 | struct RPS_Sampler *sampler; | 535 | struct RPS_Sampler *sampler; |
536 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
537 | 536 | ||
538 | gpc->get_peer_task = NULL; | 537 | gpc->get_peer_task = NULL; |
539 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
540 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
541 | return; | ||
542 | sampler = gpc->req_handle->sampler; | 538 | sampler = gpc->req_handle->sampler; |
543 | 539 | ||
544 | /**; | 540 | /**; |
@@ -588,12 +584,8 @@ sampler_mod_get_rand_peer (void *cls) | |||
588 | struct RPS_SamplerElement *s_elem; | 584 | struct RPS_SamplerElement *s_elem; |
589 | struct GNUNET_TIME_Relative last_request_diff; | 585 | struct GNUNET_TIME_Relative last_request_diff; |
590 | struct RPS_Sampler *sampler; | 586 | struct RPS_Sampler *sampler; |
591 | const struct GNUNET_SCHEDULER_TaskContext *tc; | ||
592 | 587 | ||
593 | gpc->get_peer_task = NULL; | 588 | gpc->get_peer_task = NULL; |
594 | tc = GNUNET_SCHEDULER_get_task_context (); | ||
595 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
596 | return; | ||
597 | sampler = gpc->req_handle->sampler; | 589 | sampler = gpc->req_handle->sampler; |
598 | 590 | ||
599 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Single peer was requested\n"); | 591 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Single peer was requested\n"); |
@@ -607,7 +599,8 @@ sampler_mod_get_rand_peer (void *cls) | |||
607 | 599 | ||
608 | if (EMPTY == s_elem->is_empty) | 600 | if (EMPTY == s_elem->is_empty) |
609 | { | 601 | { |
610 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sampler_mod element empty, rescheduling.\n"); | 602 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
603 | "Sampler_mod element empty, rescheduling.\n"); | ||
611 | GNUNET_assert (NULL == gpc->get_peer_task); | 604 | GNUNET_assert (NULL == gpc->get_peer_task); |
612 | gpc->get_peer_task = | 605 | gpc->get_peer_task = |
613 | GNUNET_SCHEDULER_add_delayed (sampler->max_round_interval, | 606 | GNUNET_SCHEDULER_add_delayed (sampler->max_round_interval, |
@@ -708,7 +701,8 @@ RPS_sampler_get_n_rand_peers (struct RPS_Sampler *sampler, | |||
708 | req_handle->gpc_tail, | 701 | req_handle->gpc_tail, |
709 | gpc); | 702 | gpc); |
710 | // maybe add a little delay | 703 | // maybe add a little delay |
711 | gpc->get_peer_task = GNUNET_SCHEDULER_add_now (sampler->get_peers, gpc); | 704 | gpc->get_peer_task = GNUNET_SCHEDULER_add_now (sampler->get_peers, |
705 | gpc); | ||
712 | } | 706 | } |
713 | return req_handle; | 707 | return req_handle; |
714 | } | 708 | } |
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index aca58d55e..128a81f21 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -38,7 +38,7 @@ | |||
38 | /** | 38 | /** |
39 | * How many peers do we start? | 39 | * How many peers do we start? |
40 | */ | 40 | */ |
41 | uint32_t num_peers; | 41 | static uint32_t num_peers; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * How long do we run the test? | 44 | * How long do we run the test? |
@@ -256,19 +256,12 @@ static unsigned int num_peers_online; | |||
256 | */ | 256 | */ |
257 | static int ok; | 257 | static int ok; |
258 | 258 | ||
259 | |||
260 | /** | 259 | /** |
261 | * Identifier for the churn task that runs periodically | 260 | * Identifier for the churn task that runs periodically |
262 | */ | 261 | */ |
263 | static struct GNUNET_SCHEDULER_Task *churn_task; | 262 | static struct GNUNET_SCHEDULER_Task *churn_task; |
264 | 263 | ||
265 | /** | 264 | /** |
266 | * Identifier for the churn task that runs periodically | ||
267 | */ | ||
268 | static struct GNUNET_SCHEDULER_Task *shutdown_task; | ||
269 | |||
270 | |||
271 | /** | ||
272 | * Called to initialise the given RPSPeer | 265 | * Called to initialise the given RPSPeer |
273 | */ | 266 | */ |
274 | typedef void (*InitPeer) (struct RPSPeer *rps_peer); | 267 | typedef void (*InitPeer) (struct RPSPeer *rps_peer); |
@@ -362,7 +355,7 @@ static int in_shutdown; | |||
362 | * Append arguments to file | 355 | * Append arguments to file |
363 | */ | 356 | */ |
364 | static void | 357 | static void |
365 | tofile_ (const char *file_name, char *line) | 358 | tofile_ (const char *file_name, const char *line) |
366 | { | 359 | { |
367 | struct GNUNET_DISK_FileHandle *f; | 360 | struct GNUNET_DISK_FileHandle *f; |
368 | /* char output_buffer[512]; */ | 361 | /* char output_buffer[512]; */ |
@@ -754,8 +747,7 @@ default_reply_handle (void *cls, | |||
754 | 747 | ||
755 | if (0 == evaluate ()) | 748 | if (0 == evaluate ()) |
756 | { | 749 | { |
757 | GNUNET_SCHEDULER_cancel (shutdown_task); | 750 | GNUNET_SCHEDULER_shutdown (); |
758 | shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL); | ||
759 | } | 751 | } |
760 | } | 752 | } |
761 | 753 | ||
@@ -1388,7 +1380,7 @@ run (void *cls, | |||
1388 | 1380 | ||
1389 | if (NULL != churn_task) | 1381 | if (NULL != churn_task) |
1390 | GNUNET_SCHEDULER_cancel (churn_task); | 1382 | GNUNET_SCHEDULER_cancel (churn_task); |
1391 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); | 1383 | GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); |
1392 | } | 1384 | } |
1393 | 1385 | ||
1394 | 1386 | ||