diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-08 18:19:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-08 18:19:52 +0000 |
commit | b2bdeca1c78a40abb2f2295c48a31f92e6e32ec0 (patch) | |
tree | 5324cedba75f6598234d260621b01bc96579b5d2 /src/core/test_core_api_reliability.c | |
parent | c32824526668948c5555f95ef545733004cc5e4a (diff) | |
download | gnunet-b2bdeca1c78a40abb2f2295c48a31f92e6e32ec0.tar.gz gnunet-b2bdeca1c78a40abb2f2295c48a31f92e6e32ec0.zip |
-fix cancellations in test
Diffstat (limited to 'src/core/test_core_api_reliability.c')
-rw-r--r-- | src/core/test_core_api_reliability.c | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index 10cef0e0d..99eb7ea21 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c | |||
@@ -61,7 +61,7 @@ struct PeerContext | |||
61 | struct GNUNET_CONFIGURATION_Handle *cfg; | 61 | struct GNUNET_CONFIGURATION_Handle *cfg; |
62 | struct GNUNET_CORE_Handle *ch; | 62 | struct GNUNET_CORE_Handle *ch; |
63 | struct GNUNET_PeerIdentity id; | 63 | struct GNUNET_PeerIdentity id; |
64 | struct GNUNET_TRANSPORT_Handle *th; | 64 | struct GNUNET_TRANSPORT_OfferHelloHandle *oh; |
65 | struct GNUNET_MessageHeader *hello; | 65 | struct GNUNET_MessageHeader *hello; |
66 | struct GNUNET_TRANSPORT_GetHelloHandle *ghh; | 66 | struct GNUNET_TRANSPORT_GetHelloHandle *ghh; |
67 | struct GNUNET_ATS_ConnectivityHandle *ats; | 67 | struct GNUNET_ATS_ConnectivityHandle *ats; |
@@ -108,11 +108,15 @@ terminate_peer (struct PeerContext *p) | |||
108 | GNUNET_CORE_disconnect (p->ch); | 108 | GNUNET_CORE_disconnect (p->ch); |
109 | p->ch = NULL; | 109 | p->ch = NULL; |
110 | } | 110 | } |
111 | if (NULL != p->th) | 111 | if (NULL != p->ghh) |
112 | { | 112 | { |
113 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); | 113 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); |
114 | GNUNET_TRANSPORT_disconnect (p->th); | 114 | p->ghh = NULL; |
115 | p->th = NULL; | 115 | } |
116 | if (NULL != p->oh) | ||
117 | { | ||
118 | GNUNET_TRANSPORT_offer_hello_cancel (p->oh); | ||
119 | p->oh = NULL; | ||
116 | } | 120 | } |
117 | if (NULL != p->ats_sh) | 121 | if (NULL != p->ats_sh) |
118 | { | 122 | { |
@@ -402,6 +406,15 @@ init_notify (void *cls, | |||
402 | 406 | ||
403 | 407 | ||
404 | static void | 408 | static void |
409 | offer_hello_done (void *cls) | ||
410 | { | ||
411 | struct PeerContext *p = cls; | ||
412 | |||
413 | p->oh = NULL; | ||
414 | } | ||
415 | |||
416 | |||
417 | static void | ||
405 | process_hello (void *cls, | 418 | process_hello (void *cls, |
406 | const struct GNUNET_MessageHeader *message) | 419 | const struct GNUNET_MessageHeader *message) |
407 | { | 420 | { |
@@ -411,15 +424,27 @@ process_hello (void *cls, | |||
411 | "Received (my) `%s' from transport service\n", "HELLO"); | 424 | "Received (my) `%s' from transport service\n", "HELLO"); |
412 | GNUNET_assert (message != NULL); | 425 | GNUNET_assert (message != NULL); |
413 | p->hello = GNUNET_copy_message (message); | 426 | p->hello = GNUNET_copy_message (message); |
414 | if ((p == &p1) && (p2.th != NULL)) | 427 | if ((p == &p1) && (NULL == p2.oh)) |
415 | GNUNET_TRANSPORT_offer_hello (p2.cfg, message, NULL, NULL); | 428 | p2.oh = GNUNET_TRANSPORT_offer_hello (p2.cfg, |
416 | if ((p == &p2) && (p1.th != NULL)) | 429 | message, |
417 | GNUNET_TRANSPORT_offer_hello (p1.cfg, message, NULL, NULL); | 430 | &offer_hello_done, |
418 | 431 | &p2); | |
419 | if ((p == &p1) && (p2.hello != NULL)) | 432 | if ((p == &p2) && (NULL == p1.oh)) |
420 | GNUNET_TRANSPORT_offer_hello (p1.cfg, p2.hello, NULL, NULL); | 433 | p1.oh = GNUNET_TRANSPORT_offer_hello (p1.cfg, |
421 | if ((p == &p2) && (p1.hello != NULL)) | 434 | message, |
422 | GNUNET_TRANSPORT_offer_hello (p2.cfg, p1.hello, NULL, NULL); | 435 | &offer_hello_done, |
436 | &p1); | ||
437 | |||
438 | if ((p == &p1) && (p2.hello != NULL) && (NULL == p1.oh) ) | ||
439 | p1.oh = GNUNET_TRANSPORT_offer_hello (p1.cfg, | ||
440 | p2.hello, | ||
441 | &offer_hello_done, | ||
442 | &p1); | ||
443 | if ((p == &p2) && (p1.hello != NULL) && (NULL == p2.oh) ) | ||
444 | p2.oh = GNUNET_TRANSPORT_offer_hello (p2.cfg, | ||
445 | p1.hello, | ||
446 | &offer_hello_done, | ||
447 | &p2); | ||
423 | } | 448 | } |
424 | 449 | ||
425 | 450 | ||
@@ -438,11 +463,11 @@ setup_peer (struct PeerContext *p, | |||
438 | "gnunet-service-arm", | 463 | "gnunet-service-arm", |
439 | "-c", cfgname, NULL); | 464 | "-c", cfgname, NULL); |
440 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 465 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
441 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); | ||
442 | GNUNET_assert (p->th != NULL); | ||
443 | p->ats = GNUNET_ATS_connectivity_init (p->cfg); | 466 | p->ats = GNUNET_ATS_connectivity_init (p->cfg); |
444 | GNUNET_assert (NULL != p->ats); | 467 | GNUNET_assert (NULL != p->ats); |
445 | p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg, &process_hello, p); | 468 | p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg, |
469 | &process_hello, | ||
470 | p); | ||
446 | GNUNET_free (binary); | 471 | GNUNET_free (binary); |
447 | } | 472 | } |
448 | 473 | ||