diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-10-08 21:50:34 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-10-08 21:50:34 +0200 |
commit | bd8f79f628b254f4f02c08284ba65d23486d6127 (patch) | |
tree | 8729cfd715433db91b0fbb72d0aac164082b7f24 /src/transport | |
parent | 6ef071b8ccea72da6a9e1eee6483c326b6ebc082 (diff) | |
download | gnunet-bd8f79f628b254f4f02c08284ba65d23486d6127.tar.gz gnunet-bd8f79f628b254f4f02c08284ba65d23486d6127.zip |
-clean up testing-NG finish logic
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/transport_api_cmd_connecting_peers.c | 49 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_connecting_peers_v2.c | 24 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_connecting_peers_v3.c | 48 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_start_peer.c | 42 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_start_peer_v2.c | 1 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_start_peer_v3.c | 1 |
6 files changed, 52 insertions, 113 deletions
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index ddf1c3872..82194ff15 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c | |||
@@ -42,6 +42,11 @@ | |||
42 | */ | 42 | */ |
43 | struct ConnectPeersState | 43 | struct ConnectPeersState |
44 | { | 44 | { |
45 | /** | ||
46 | * Context for our asynchronous completion. | ||
47 | */ | ||
48 | struct GNUNET_TESTING_AsyncContext ac; | ||
49 | |||
45 | // Label of the cmd which started the test system. | 50 | // Label of the cmd which started the test system. |
46 | const char *create_label; | 51 | const char *create_label; |
47 | 52 | ||
@@ -183,6 +188,7 @@ connect_peers_run (void *cls, | |||
183 | * The finish function of this cmd will check if the peer we are trying to connect to is in the connected peers map of the start peer cmd for this peer. | 188 | * The finish function of this cmd will check if the peer we are trying to connect to is in the connected peers map of the start peer cmd for this peer. |
184 | * | 189 | * |
185 | */ | 190 | */ |
191 | // FIXME: this needs a complete rewrite! | ||
186 | static int | 192 | static int |
187 | connect_peers_finish (void *cls, | 193 | connect_peers_finish (void *cls, |
188 | GNUNET_SCHEDULER_TaskCallback cont, | 194 | GNUNET_SCHEDULER_TaskCallback cont, |
@@ -222,20 +228,6 @@ connect_peers_finish (void *cls, | |||
222 | 228 | ||
223 | 229 | ||
224 | /** | 230 | /** |
225 | * Trait function of this cmd does nothing. | ||
226 | * | ||
227 | */ | ||
228 | static int | ||
229 | connect_peers_traits (void *cls, | ||
230 | const void **ret, | ||
231 | const char *trait, | ||
232 | unsigned int index) | ||
233 | { | ||
234 | return GNUNET_OK; | ||
235 | } | ||
236 | |||
237 | |||
238 | /** | ||
239 | * The cleanup function of this cmd frees resources the cmd allocated. | 231 | * The cleanup function of this cmd frees resources the cmd allocated. |
240 | * | 232 | * |
241 | */ | 233 | */ |
@@ -249,13 +241,6 @@ connect_peers_cleanup (void *cls) | |||
249 | } | 241 | } |
250 | 242 | ||
251 | 243 | ||
252 | /** | ||
253 | * Create command. | ||
254 | * | ||
255 | * @param label name for command. | ||
256 | * @param start_peer_label Label of the cmd to start a peer. | ||
257 | * @return command. | ||
258 | */ | ||
259 | struct GNUNET_TESTING_Command | 244 | struct GNUNET_TESTING_Command |
260 | GNUNET_TRANSPORT_cmd_connect_peers (const char *label, | 245 | GNUNET_TRANSPORT_cmd_connect_peers (const char *label, |
261 | const char *start_peer_label, | 246 | const char *start_peer_label, |
@@ -269,15 +254,15 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label, | |||
269 | cps->num = num; | 254 | cps->num = num; |
270 | cps->create_label = create_label; | 255 | cps->create_label = create_label; |
271 | 256 | ||
272 | 257 | { | |
273 | struct GNUNET_TESTING_Command cmd = { | 258 | struct GNUNET_TESTING_Command cmd = { |
274 | .cls = cps, | 259 | .cls = cps, |
275 | .label = label, | 260 | .label = label, |
276 | .run = &connect_peers_run, | 261 | .run = &connect_peers_run, |
277 | .finish = &connect_peers_finish, | 262 | .ac = &cps->ac, |
278 | .cleanup = &connect_peers_cleanup, | 263 | .cleanup = &connect_peers_cleanup |
279 | .traits = &connect_peers_traits | 264 | }; |
280 | }; | 265 | |
281 | 266 | return cmd; | |
282 | return cmd; | 267 | } |
283 | } | 268 | } |
diff --git a/src/transport/transport_api_cmd_connecting_peers_v2.c b/src/transport/transport_api_cmd_connecting_peers_v2.c index 8ef556946..8d0f74916 100644 --- a/src/transport/transport_api_cmd_connecting_peers_v2.c +++ b/src/transport/transport_api_cmd_connecting_peers_v2.c | |||
@@ -44,6 +44,11 @@ | |||
44 | */ | 44 | */ |
45 | struct ConnectPeersState | 45 | struct ConnectPeersState |
46 | { | 46 | { |
47 | /** | ||
48 | * Context for our asynchronous completion. | ||
49 | */ | ||
50 | struct GNUNET_TESTING_AsyncContext ac; | ||
51 | |||
47 | // Label of the cmd which started the test system. | 52 | // Label of the cmd which started the test system. |
48 | const char *create_label; | 53 | const char *create_label; |
49 | 54 | ||
@@ -185,20 +190,6 @@ connect_peers_finish (void *cls, | |||
185 | 190 | ||
186 | 191 | ||
187 | /** | 192 | /** |
188 | * Trait function of this cmd does nothing. | ||
189 | * | ||
190 | */ | ||
191 | static int | ||
192 | connect_peers_traits (void *cls, | ||
193 | const void **ret, | ||
194 | const char *trait, | ||
195 | unsigned int index) | ||
196 | { | ||
197 | return GNUNET_OK; | ||
198 | } | ||
199 | |||
200 | |||
201 | /** | ||
202 | * The cleanup function of this cmd frees resources the cmd allocated. | 193 | * The cleanup function of this cmd frees resources the cmd allocated. |
203 | * | 194 | * |
204 | */ | 195 | */ |
@@ -237,9 +228,8 @@ GNUNET_TRANSPORT_cmd_connect_peers_v2 (const char *label, | |||
237 | .cls = cps, | 228 | .cls = cps, |
238 | .label = label, | 229 | .label = label, |
239 | .run = &connect_peers_run, | 230 | .run = &connect_peers_run, |
240 | .finish = &connect_peers_finish, | 231 | .ac = &cps->ac, |
241 | .cleanup = &connect_peers_cleanup, | 232 | .cleanup = &connect_peers_cleanup |
242 | .traits = &connect_peers_traits | ||
243 | }; | 233 | }; |
244 | 234 | ||
245 | return cmd; | 235 | return cmd; |
diff --git a/src/transport/transport_api_cmd_connecting_peers_v3.c b/src/transport/transport_api_cmd_connecting_peers_v3.c index a73d81064..ae32a087a 100644 --- a/src/transport/transport_api_cmd_connecting_peers_v3.c +++ b/src/transport/transport_api_cmd_connecting_peers_v3.c | |||
@@ -59,6 +59,11 @@ | |||
59 | struct ConnectPeersState | 59 | struct ConnectPeersState |
60 | { | 60 | { |
61 | /** | 61 | /** |
62 | * Context for our asynchronous completion. | ||
63 | */ | ||
64 | struct GNUNET_TESTING_AsyncContext ac; | ||
65 | |||
66 | /** | ||
62 | * The testing system of this node. | 67 | * The testing system of this node. |
63 | */ | 68 | */ |
64 | struct GNUNET_TESTING_System *tl_system; | 69 | struct GNUNET_TESTING_System *tl_system; |
@@ -448,20 +453,6 @@ connect_peers_finish (void *cls, | |||
448 | 453 | ||
449 | 454 | ||
450 | /** | 455 | /** |
451 | * Trait function of this cmd does nothing. | ||
452 | * | ||
453 | */ | ||
454 | static int | ||
455 | connect_peers_traits (void *cls, | ||
456 | const void **ret, | ||
457 | const char *trait, | ||
458 | unsigned int index) | ||
459 | { | ||
460 | return GNUNET_OK; | ||
461 | } | ||
462 | |||
463 | |||
464 | /** | ||
465 | * The cleanup function of this cmd frees resources the cmd allocated. | 456 | * The cleanup function of this cmd frees resources the cmd allocated. |
466 | * | 457 | * |
467 | */ | 458 | */ |
@@ -475,13 +466,6 @@ connect_peers_cleanup (void *cls) | |||
475 | } | 466 | } |
476 | 467 | ||
477 | 468 | ||
478 | /** | ||
479 | * Create command. | ||
480 | * | ||
481 | * @param label name for command. | ||
482 | * @param start_peer_label Label of the cmd to start a peer. | ||
483 | * @return command. | ||
484 | */ | ||
485 | struct GNUNET_TESTING_Command | 469 | struct GNUNET_TESTING_Command |
486 | GNUNET_TRANSPORT_cmd_connect_peers_v3 (const char *label, | 470 | GNUNET_TRANSPORT_cmd_connect_peers_v3 (const char *label, |
487 | const char *start_peer_label, | 471 | const char *start_peer_label, |
@@ -498,15 +482,15 @@ GNUNET_TRANSPORT_cmd_connect_peers_v3 (const char *label, | |||
498 | cps->create_label = create_label; | 482 | cps->create_label = create_label; |
499 | cps->topology = topology; | 483 | cps->topology = topology; |
500 | 484 | ||
501 | 485 | { | |
502 | struct GNUNET_TESTING_Command cmd = { | 486 | struct GNUNET_TESTING_Command cmd = { |
503 | .cls = cps, | 487 | .cls = cps, |
504 | .label = label, | 488 | .label = label, |
505 | .run = &connect_peers_run, | 489 | .run = &connect_peers_run, |
506 | .finish = &connect_peers_finish, | 490 | .ac = &cps->ac, |
507 | .cleanup = &connect_peers_cleanup, | 491 | .cleanup = &connect_peers_cleanup |
508 | .traits = &connect_peers_traits | 492 | }; |
509 | }; | 493 | |
510 | 494 | return cmd; | |
511 | return cmd; | 495 | } |
512 | } | 496 | } |
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c index 8a53ed22c..44fc68807 100644 --- a/src/transport/transport_api_cmd_start_peer.c +++ b/src/transport/transport_api_cmd_start_peer.c | |||
@@ -51,6 +51,7 @@ hello_iter_cb (void *cb_cls, | |||
51 | const char *emsg) | 51 | const char *emsg) |
52 | { | 52 | { |
53 | struct StartPeerState *sps = cb_cls; | 53 | struct StartPeerState *sps = cb_cls; |
54 | |||
54 | if (NULL == record) | 55 | if (NULL == record) |
55 | { | 56 | { |
56 | sps->pic = NULL; | 57 | sps->pic = NULL; |
@@ -90,26 +91,6 @@ retrieve_hello (void *cls) | |||
90 | 91 | ||
91 | 92 | ||
92 | /** | 93 | /** |
93 | * This function checks StartPeerState#finished, which is set when the hello was retrieved. | ||
94 | * | ||
95 | */ | ||
96 | static int | ||
97 | start_peer_finish (void *cls, | ||
98 | GNUNET_SCHEDULER_TaskCallback cont, | ||
99 | void *cont_cls) | ||
100 | { | ||
101 | struct StartPeerState *sps = cls; | ||
102 | |||
103 | if (GNUNET_YES == sps->finished) | ||
104 | { | ||
105 | cont (cont_cls); | ||
106 | } | ||
107 | |||
108 | return sps->finished; | ||
109 | } | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Disconnect callback for the connection to the core service. | 94 | * Disconnect callback for the connection to the core service. |
114 | * | 95 | * |
115 | */ | 96 | */ |
@@ -597,14 +578,15 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label, | |||
597 | i * sizeof(struct GNUNET_MQ_MessageHandler)); | 578 | i * sizeof(struct GNUNET_MQ_MessageHandler)); |
598 | } | 579 | } |
599 | 580 | ||
600 | struct GNUNET_TESTING_Command cmd = { | 581 | { |
601 | .cls = sps, | 582 | struct GNUNET_TESTING_Command cmd = { |
602 | .label = label, | 583 | .cls = sps, |
603 | .run = &start_peer_run, | 584 | .label = label, |
604 | .finish = &start_peer_finish, | 585 | .run = &start_peer_run, |
605 | .cleanup = &start_peer_cleanup, | 586 | .cleanup = &start_peer_cleanup, |
606 | .traits = &start_peer_traits | 587 | .traits = &start_peer_traits |
607 | }; | 588 | }; |
608 | 589 | ||
609 | return cmd; | 590 | return cmd; |
591 | } | ||
610 | } | 592 | } |
diff --git a/src/transport/transport_api_cmd_start_peer_v2.c b/src/transport/transport_api_cmd_start_peer_v2.c index 2ab58574a..94799eddd 100644 --- a/src/transport/transport_api_cmd_start_peer_v2.c +++ b/src/transport/transport_api_cmd_start_peer_v2.c | |||
@@ -597,7 +597,6 @@ GNUNET_TRANSPORT_cmd_start_peer_v2 (const char *label, | |||
597 | .cls = sps, | 597 | .cls = sps, |
598 | .label = label, | 598 | .label = label, |
599 | .run = &start_peer_run, | 599 | .run = &start_peer_run, |
600 | .finish = &start_peer_finish, | ||
601 | .cleanup = &start_peer_cleanup, | 600 | .cleanup = &start_peer_cleanup, |
602 | .traits = &start_peer_traits | 601 | .traits = &start_peer_traits |
603 | }; | 602 | }; |
diff --git a/src/transport/transport_api_cmd_start_peer_v3.c b/src/transport/transport_api_cmd_start_peer_v3.c index fa6300ef5..1a19ce60e 100644 --- a/src/transport/transport_api_cmd_start_peer_v3.c +++ b/src/transport/transport_api_cmd_start_peer_v3.c | |||
@@ -609,7 +609,6 @@ GNUNET_TRANSPORT_cmd_start_peer_v3 (const char *label, | |||
609 | .cls = sps, | 609 | .cls = sps, |
610 | .label = label, | 610 | .label = label, |
611 | .run = &start_peer_run, | 611 | .run = &start_peer_run, |
612 | .finish = &start_peer_finish, | ||
613 | .cleanup = &start_peer_cleanup, | 612 | .cleanup = &start_peer_cleanup, |
614 | .traits = &start_peer_traits | 613 | .traits = &start_peer_traits |
615 | }; | 614 | }; |