diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-30 08:17:37 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-30 08:17:37 +0000 |
commit | 95f9076a2139f5fb042b944a0658b6cda2fa35db (patch) | |
tree | b0826a2a1dcf812e6b4450fe6b05d47cd53ae49d /src/psyc/test_psyc.c | |
parent | 7746f68db77b9ca3c4aaca24ab2ce5253461240b (diff) | |
download | gnunet-95f9076a2139f5fb042b944a0658b6cda2fa35db.tar.gz gnunet-95f9076a2139f5fb042b944a0658b6cda2fa35db.zip |
implementing new scheduler shutdown semantics
Diffstat (limited to 'src/psyc/test_psyc.c')
-rw-r--r-- | src/psyc/test_psyc.c | 117 |
1 files changed, 61 insertions, 56 deletions
diff --git a/src/psyc/test_psyc.c b/src/psyc/test_psyc.c index 1169b49d5..5ea83dd63 100644 --- a/src/psyc/test_psyc.c +++ b/src/psyc/test_psyc.c | |||
@@ -41,28 +41,28 @@ | |||
41 | /** | 41 | /** |
42 | * Return value from 'main'. | 42 | * Return value from 'main'. |
43 | */ | 43 | */ |
44 | int res; | 44 | static int res; |
45 | 45 | ||
46 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 46 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
47 | 47 | ||
48 | struct GNUNET_CORE_Handle *core; | 48 | static struct GNUNET_CORE_Handle *core; |
49 | struct GNUNET_PeerIdentity this_peer; | 49 | static struct GNUNET_PeerIdentity this_peer; |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * Handle for task for timeout termination. | 52 | * Handle for task for timeout termination. |
53 | */ | 53 | */ |
54 | struct GNUNET_SCHEDULER_Task * end_badly_task; | 54 | static struct GNUNET_SCHEDULER_Task * end_badly_task; |
55 | 55 | ||
56 | struct GNUNET_PSYC_Master *mst; | 56 | static struct GNUNET_PSYC_Master *mst; |
57 | struct GNUNET_PSYC_Slave *slv; | 57 | static struct GNUNET_PSYC_Slave *slv; |
58 | 58 | ||
59 | struct GNUNET_PSYC_Channel *mst_chn, *slv_chn; | 59 | static struct GNUNET_PSYC_Channel *mst_chn, *slv_chn; |
60 | 60 | ||
61 | struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; | 61 | static struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; |
62 | struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key; | 62 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key; |
63 | 63 | ||
64 | struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key; | 64 | static struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key; |
65 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key; | 65 | static struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key; |
66 | 66 | ||
67 | struct TransmitClosure | 67 | struct TransmitClosure |
68 | { | 68 | { |
@@ -79,9 +79,9 @@ struct TransmitClosure | |||
79 | uint8_t n; | 79 | uint8_t n; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | struct TransmitClosure *tmit; | 82 | static struct TransmitClosure *tmit; |
83 | 83 | ||
84 | uint8_t join_req_count, end_count; | 84 | static uint8_t join_req_count, end_count; |
85 | 85 | ||
86 | enum | 86 | enum |
87 | { | 87 | { |
@@ -104,14 +104,15 @@ enum | |||
104 | } test; | 104 | } test; |
105 | 105 | ||
106 | 106 | ||
107 | void | 107 | static void |
108 | master_transmit (); | 108 | master_transmit (); |
109 | 109 | ||
110 | void | 110 | static void |
111 | master_history_replay_latest (); | 111 | master_history_replay_latest (); |
112 | 112 | ||
113 | 113 | ||
114 | void master_stopped (void *cls) | 114 | static void |
115 | master_stopped (void *cls) | ||
115 | { | 116 | { |
116 | if (NULL != tmit) | 117 | if (NULL != tmit) |
117 | { | 118 | { |
@@ -122,7 +123,9 @@ void master_stopped (void *cls) | |||
122 | GNUNET_SCHEDULER_shutdown (); | 123 | GNUNET_SCHEDULER_shutdown (); |
123 | } | 124 | } |
124 | 125 | ||
125 | void slave_parted (void *cls) | 126 | |
127 | static void | ||
128 | slave_parted (void *cls) | ||
126 | { | 129 | { |
127 | if (NULL != mst) | 130 | if (NULL != mst) |
128 | { | 131 | { |
@@ -133,10 +136,11 @@ void slave_parted (void *cls) | |||
133 | master_stopped (NULL); | 136 | master_stopped (NULL); |
134 | } | 137 | } |
135 | 138 | ||
139 | |||
136 | /** | 140 | /** |
137 | * Clean up all resources used. | 141 | * Clean up all resources used. |
138 | */ | 142 | */ |
139 | void | 143 | static void |
140 | cleanup () | 144 | cleanup () |
141 | { | 145 | { |
142 | if (NULL != core) | 146 | if (NULL != core) |
@@ -185,7 +189,7 @@ end_normally (void *cls) | |||
185 | /** | 189 | /** |
186 | * Finish the test case (successfully). | 190 | * Finish the test case (successfully). |
187 | */ | 191 | */ |
188 | void | 192 | static void |
189 | end () | 193 | end () |
190 | { | 194 | { |
191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending tests.\n"); | 195 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending tests.\n"); |
@@ -200,7 +204,7 @@ end () | |||
200 | } | 204 | } |
201 | 205 | ||
202 | 206 | ||
203 | void | 207 | static void |
204 | master_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) | 208 | master_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) |
205 | { | 209 | { |
206 | GNUNET_assert (NULL != msg); | 210 | GNUNET_assert (NULL != msg); |
@@ -213,7 +217,7 @@ master_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) | |||
213 | } | 217 | } |
214 | 218 | ||
215 | 219 | ||
216 | void | 220 | static void |
217 | master_message_part_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg, | 221 | master_message_part_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg, |
218 | const struct GNUNET_MessageHeader *pmsg) | 222 | const struct GNUNET_MessageHeader *pmsg) |
219 | { | 223 | { |
@@ -270,7 +274,7 @@ master_message_part_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg, | |||
270 | } | 274 | } |
271 | 275 | ||
272 | 276 | ||
273 | void | 277 | static void |
274 | slave_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) | 278 | slave_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) |
275 | { | 279 | { |
276 | GNUNET_assert (NULL != msg); | 280 | GNUNET_assert (NULL != msg); |
@@ -283,7 +287,7 @@ slave_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) | |||
283 | } | 287 | } |
284 | 288 | ||
285 | 289 | ||
286 | void | 290 | static void |
287 | slave_message_part_cb (void *cls, | 291 | slave_message_part_cb (void *cls, |
288 | const struct GNUNET_PSYC_MessageHeader *msg, | 292 | const struct GNUNET_PSYC_MessageHeader *msg, |
289 | const struct GNUNET_MessageHeader *pmsg) | 293 | const struct GNUNET_MessageHeader *pmsg) |
@@ -326,7 +330,7 @@ slave_message_part_cb (void *cls, | |||
326 | } | 330 | } |
327 | 331 | ||
328 | 332 | ||
329 | void | 333 | static void |
330 | state_get_var (void *cls, const struct GNUNET_MessageHeader *mod, | 334 | state_get_var (void *cls, const struct GNUNET_MessageHeader *mod, |
331 | const char *name, const void *value, | 335 | const char *name, const void *value, |
332 | uint32_t value_size, uint32_t full_value_size) | 336 | uint32_t value_size, uint32_t full_value_size) |
@@ -338,7 +342,7 @@ state_get_var (void *cls, const struct GNUNET_MessageHeader *mod, | |||
338 | 342 | ||
339 | /*** Slave state_get_prefix() ***/ | 343 | /*** Slave state_get_prefix() ***/ |
340 | 344 | ||
341 | void | 345 | static void |
342 | slave_state_get_prefix_result (void *cls, int64_t result, | 346 | slave_state_get_prefix_result (void *cls, int64_t result, |
343 | const void *err_msg, uint16_t err_msg_size) | 347 | const void *err_msg, uint16_t err_msg_size) |
344 | { | 348 | { |
@@ -350,7 +354,7 @@ slave_state_get_prefix_result (void *cls, int64_t result, | |||
350 | } | 354 | } |
351 | 355 | ||
352 | 356 | ||
353 | void | 357 | static void |
354 | slave_state_get_prefix () | 358 | slave_state_get_prefix () |
355 | { | 359 | { |
356 | test = TEST_SLAVE_STATE_GET_PREFIX; | 360 | test = TEST_SLAVE_STATE_GET_PREFIX; |
@@ -362,7 +366,7 @@ slave_state_get_prefix () | |||
362 | /*** Master state_get_prefix() ***/ | 366 | /*** Master state_get_prefix() ***/ |
363 | 367 | ||
364 | 368 | ||
365 | void | 369 | static void |
366 | master_state_get_prefix_result (void *cls, int64_t result, | 370 | master_state_get_prefix_result (void *cls, int64_t result, |
367 | const void *err_msg, uint16_t err_msg_size) | 371 | const void *err_msg, uint16_t err_msg_size) |
368 | { | 372 | { |
@@ -373,7 +377,7 @@ master_state_get_prefix_result (void *cls, int64_t result, | |||
373 | } | 377 | } |
374 | 378 | ||
375 | 379 | ||
376 | void | 380 | static void |
377 | master_state_get_prefix () | 381 | master_state_get_prefix () |
378 | { | 382 | { |
379 | test = TEST_MASTER_STATE_GET_PREFIX; | 383 | test = TEST_MASTER_STATE_GET_PREFIX; |
@@ -385,7 +389,7 @@ master_state_get_prefix () | |||
385 | /*** Slave state_get() ***/ | 389 | /*** Slave state_get() ***/ |
386 | 390 | ||
387 | 391 | ||
388 | void | 392 | static void |
389 | slave_state_get_result (void *cls, int64_t result, | 393 | slave_state_get_result (void *cls, int64_t result, |
390 | const void *err_msg, uint16_t err_msg_size) | 394 | const void *err_msg, uint16_t err_msg_size) |
391 | { | 395 | { |
@@ -397,7 +401,7 @@ slave_state_get_result (void *cls, int64_t result, | |||
397 | } | 401 | } |
398 | 402 | ||
399 | 403 | ||
400 | void | 404 | static void |
401 | slave_state_get () | 405 | slave_state_get () |
402 | { | 406 | { |
403 | test = TEST_SLAVE_STATE_GET; | 407 | test = TEST_SLAVE_STATE_GET; |
@@ -409,7 +413,7 @@ slave_state_get () | |||
409 | /*** Master state_get() ***/ | 413 | /*** Master state_get() ***/ |
410 | 414 | ||
411 | 415 | ||
412 | void | 416 | static void |
413 | master_state_get_result (void *cls, int64_t result, | 417 | master_state_get_result (void *cls, int64_t result, |
414 | const void *err_msg, uint16_t err_msg_size) | 418 | const void *err_msg, uint16_t err_msg_size) |
415 | { | 419 | { |
@@ -421,7 +425,7 @@ master_state_get_result (void *cls, int64_t result, | |||
421 | } | 425 | } |
422 | 426 | ||
423 | 427 | ||
424 | void | 428 | static void |
425 | master_state_get () | 429 | master_state_get () |
426 | { | 430 | { |
427 | test = TEST_MASTER_STATE_GET; | 431 | test = TEST_MASTER_STATE_GET; |
@@ -432,7 +436,7 @@ master_state_get () | |||
432 | 436 | ||
433 | /*** Slave history_replay() ***/ | 437 | /*** Slave history_replay() ***/ |
434 | 438 | ||
435 | void | 439 | static void |
436 | slave_history_replay_result (void *cls, int64_t result, | 440 | slave_history_replay_result (void *cls, int64_t result, |
437 | const void *err_msg, uint16_t err_msg_size) | 441 | const void *err_msg, uint16_t err_msg_size) |
438 | { | 442 | { |
@@ -445,7 +449,7 @@ slave_history_replay_result (void *cls, int64_t result, | |||
445 | } | 449 | } |
446 | 450 | ||
447 | 451 | ||
448 | void | 452 | static void |
449 | slave_history_replay () | 453 | slave_history_replay () |
450 | { | 454 | { |
451 | test = TEST_SLAVE_HISTORY_REPLAY; | 455 | test = TEST_SLAVE_HISTORY_REPLAY; |
@@ -460,7 +464,7 @@ slave_history_replay () | |||
460 | /*** Master history_replay() ***/ | 464 | /*** Master history_replay() ***/ |
461 | 465 | ||
462 | 466 | ||
463 | void | 467 | static void |
464 | master_history_replay_result (void *cls, int64_t result, | 468 | master_history_replay_result (void *cls, int64_t result, |
465 | const void *err_msg, uint16_t err_msg_size) | 469 | const void *err_msg, uint16_t err_msg_size) |
466 | { | 470 | { |
@@ -473,7 +477,7 @@ master_history_replay_result (void *cls, int64_t result, | |||
473 | } | 477 | } |
474 | 478 | ||
475 | 479 | ||
476 | void | 480 | static void |
477 | master_history_replay () | 481 | master_history_replay () |
478 | { | 482 | { |
479 | test = TEST_MASTER_HISTORY_REPLAY; | 483 | test = TEST_MASTER_HISTORY_REPLAY; |
@@ -488,7 +492,7 @@ master_history_replay () | |||
488 | /*** Slave history_replay_latest() ***/ | 492 | /*** Slave history_replay_latest() ***/ |
489 | 493 | ||
490 | 494 | ||
491 | void | 495 | static void |
492 | slave_history_replay_latest_result (void *cls, int64_t result, | 496 | slave_history_replay_latest_result (void *cls, int64_t result, |
493 | const void *err_msg, uint16_t err_msg_size) | 497 | const void *err_msg, uint16_t err_msg_size) |
494 | { | 498 | { |
@@ -501,7 +505,7 @@ slave_history_replay_latest_result (void *cls, int64_t result, | |||
501 | } | 505 | } |
502 | 506 | ||
503 | 507 | ||
504 | void | 508 | static void |
505 | slave_history_replay_latest () | 509 | slave_history_replay_latest () |
506 | { | 510 | { |
507 | test = TEST_SLAVE_HISTORY_REPLAY_LATEST; | 511 | test = TEST_SLAVE_HISTORY_REPLAY_LATEST; |
@@ -517,7 +521,7 @@ slave_history_replay_latest () | |||
517 | /*** Master history_replay_latest() ***/ | 521 | /*** Master history_replay_latest() ***/ |
518 | 522 | ||
519 | 523 | ||
520 | void | 524 | static void |
521 | master_history_replay_latest_result (void *cls, int64_t result, | 525 | master_history_replay_latest_result (void *cls, int64_t result, |
522 | const void *err_msg, uint16_t err_msg_size) | 526 | const void *err_msg, uint16_t err_msg_size) |
523 | { | 527 | { |
@@ -530,7 +534,7 @@ master_history_replay_latest_result (void *cls, int64_t result, | |||
530 | } | 534 | } |
531 | 535 | ||
532 | 536 | ||
533 | void | 537 | static void |
534 | master_history_replay_latest () | 538 | master_history_replay_latest () |
535 | { | 539 | { |
536 | test = TEST_MASTER_HISTORY_REPLAY_LATEST; | 540 | test = TEST_MASTER_HISTORY_REPLAY_LATEST; |
@@ -555,7 +559,7 @@ transmit_resume (void *cls) | |||
555 | } | 559 | } |
556 | 560 | ||
557 | 561 | ||
558 | int | 562 | static int |
559 | tmit_notify_data (void *cls, uint16_t *data_size, void *data) | 563 | tmit_notify_data (void *cls, uint16_t *data_size, void *data) |
560 | { | 564 | { |
561 | struct TransmitClosure *tmit = cls; | 565 | struct TransmitClosure *tmit = cls; |
@@ -598,7 +602,7 @@ tmit_notify_data (void *cls, uint16_t *data_size, void *data) | |||
598 | } | 602 | } |
599 | 603 | ||
600 | 604 | ||
601 | int | 605 | static int |
602 | tmit_notify_mod (void *cls, uint16_t *data_size, void *data, uint8_t *oper, | 606 | tmit_notify_mod (void *cls, uint16_t *data_size, void *data, uint8_t *oper, |
603 | uint32_t *full_value_size) | 607 | uint32_t *full_value_size) |
604 | { | 608 | { |
@@ -678,7 +682,7 @@ static void | |||
678 | slave_join (); | 682 | slave_join (); |
679 | 683 | ||
680 | 684 | ||
681 | void | 685 | static void |
682 | slave_transmit () | 686 | slave_transmit () |
683 | { | 687 | { |
684 | test = TEST_SLAVE_TRANSMIT; | 688 | test = TEST_SLAVE_TRANSMIT; |
@@ -702,7 +706,7 @@ slave_transmit () | |||
702 | } | 706 | } |
703 | 707 | ||
704 | 708 | ||
705 | void | 709 | static void |
706 | slave_remove_cb (void *cls, int64_t result, | 710 | slave_remove_cb (void *cls, int64_t result, |
707 | const void *err_msg, uint16_t err_msg_size) | 711 | const void *err_msg, uint16_t err_msg_size) |
708 | { | 712 | { |
@@ -714,7 +718,7 @@ slave_remove_cb (void *cls, int64_t result, | |||
714 | } | 718 | } |
715 | 719 | ||
716 | 720 | ||
717 | void | 721 | static void |
718 | slave_remove () | 722 | slave_remove () |
719 | { | 723 | { |
720 | test = TEST_SLAVE_REMOVE; | 724 | test = TEST_SLAVE_REMOVE; |
@@ -724,7 +728,7 @@ slave_remove () | |||
724 | } | 728 | } |
725 | 729 | ||
726 | 730 | ||
727 | void | 731 | static void |
728 | slave_add_cb (void *cls, int64_t result, | 732 | slave_add_cb (void *cls, int64_t result, |
729 | const void *err_msg, uint16_t err_msg_size) | 733 | const void *err_msg, uint16_t err_msg_size) |
730 | { | 734 | { |
@@ -735,7 +739,7 @@ slave_add_cb (void *cls, int64_t result, | |||
735 | } | 739 | } |
736 | 740 | ||
737 | 741 | ||
738 | void | 742 | static void |
739 | slave_add () | 743 | slave_add () |
740 | { | 744 | { |
741 | test = TEST_SLAVE_ADD; | 745 | test = TEST_SLAVE_ADD; |
@@ -744,7 +748,8 @@ slave_add () | |||
744 | } | 748 | } |
745 | 749 | ||
746 | 750 | ||
747 | void first_slave_parted (void *cls) | 751 | static void |
752 | first_slave_parted (void *cls) | ||
748 | { | 753 | { |
749 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "First slave parted.\n"); | 754 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "First slave parted.\n"); |
750 | slave_join (TEST_SLAVE_JOIN_ACCEPT); | 755 | slave_join (TEST_SLAVE_JOIN_ACCEPT); |
@@ -754,7 +759,7 @@ void first_slave_parted (void *cls) | |||
754 | static void | 759 | static void |
755 | schedule_slave_part (void *cls) | 760 | schedule_slave_part (void *cls) |
756 | { | 761 | { |
757 | GNUNET_PSYC_slave_part (slv, GNUNET_NO, first_slave_parted, NULL); | 762 | GNUNET_PSYC_slave_part (slv, GNUNET_NO, &first_slave_parted, NULL); |
758 | } | 763 | } |
759 | 764 | ||
760 | 765 | ||
@@ -772,7 +777,7 @@ join_decision_cb (void *cls, | |||
772 | case TEST_SLAVE_JOIN_REJECT: | 777 | case TEST_SLAVE_JOIN_REJECT: |
773 | GNUNET_assert (0 == is_admitted); | 778 | GNUNET_assert (0 == is_admitted); |
774 | GNUNET_assert (1 == join_req_count); | 779 | GNUNET_assert (1 == join_req_count); |
775 | GNUNET_SCHEDULER_add_now (schedule_slave_part, NULL); | 780 | GNUNET_SCHEDULER_add_now (&schedule_slave_part, NULL); |
776 | break; | 781 | break; |
777 | 782 | ||
778 | case TEST_SLAVE_JOIN_ACCEPT: | 783 | case TEST_SLAVE_JOIN_ACCEPT: |
@@ -844,7 +849,7 @@ slave_join (int t) | |||
844 | } | 849 | } |
845 | 850 | ||
846 | 851 | ||
847 | void | 852 | static void |
848 | master_transmit () | 853 | master_transmit () |
849 | { | 854 | { |
850 | test = TEST_MASTER_TRANSMIT; | 855 | test = TEST_MASTER_TRANSMIT; |
@@ -899,7 +904,7 @@ master_transmit () | |||
899 | } | 904 | } |
900 | 905 | ||
901 | 906 | ||
902 | void | 907 | static void |
903 | master_start_cb (void *cls, int result, uint64_t max_message_id) | 908 | master_start_cb (void *cls, int result, uint64_t max_message_id) |
904 | { | 909 | { |
905 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 910 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -911,7 +916,7 @@ master_start_cb (void *cls, int result, uint64_t max_message_id) | |||
911 | } | 916 | } |
912 | 917 | ||
913 | 918 | ||
914 | void | 919 | static void |
915 | master_start () | 920 | master_start () |
916 | { | 921 | { |
917 | test = TEST_MASTER_START; | 922 | test = TEST_MASTER_START; |
@@ -931,7 +936,7 @@ schedule_master_start (void *cls) | |||
931 | } | 936 | } |
932 | 937 | ||
933 | 938 | ||
934 | void | 939 | static void |
935 | core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) | 940 | core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) |
936 | { | 941 | { |
937 | this_peer = *my_identity; | 942 | this_peer = *my_identity; |
@@ -953,7 +958,7 @@ core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) | |||
953 | * @param cfg configuration we use (also to connect to PSYC service) | 958 | * @param cfg configuration we use (also to connect to PSYC service) |
954 | * @param peer handle to access more of the peer (not used) | 959 | * @param peer handle to access more of the peer (not used) |
955 | */ | 960 | */ |
956 | void | 961 | static void |
957 | #if DEBUG_TEST_PSYC | 962 | #if DEBUG_TEST_PSYC |
958 | run (void *cls, char *const *args, const char *cfgfile, | 963 | run (void *cls, char *const *args, const char *cfgfile, |
959 | const struct GNUNET_CONFIGURATION_Handle *c) | 964 | const struct GNUNET_CONFIGURATION_Handle *c) |