aboutsummaryrefslogtreecommitdiff
path: root/src/core/test_core_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-08 18:19:52 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-08 18:19:52 +0000
commitb2bdeca1c78a40abb2f2295c48a31f92e6e32ec0 (patch)
tree5324cedba75f6598234d260621b01bc96579b5d2 /src/core/test_core_api.c
parentc32824526668948c5555f95ef545733004cc5e4a (diff)
downloadgnunet-b2bdeca1c78a40abb2f2295c48a31f92e6e32ec0.tar.gz
gnunet-b2bdeca1c78a40abb2f2295c48a31f92e6e32ec0.zip
-fix cancellations in test
Diffstat (limited to 'src/core/test_core_api.c')
-rw-r--r--src/core/test_core_api.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c
index 43f4c421e..b012aa213 100644
--- a/src/core/test_core_api.c
+++ b/src/core/test_core_api.c
@@ -35,7 +35,7 @@ struct PeerContext
35 struct GNUNET_CONFIGURATION_Handle *cfg; 35 struct GNUNET_CONFIGURATION_Handle *cfg;
36 struct GNUNET_CORE_Handle *ch; 36 struct GNUNET_CORE_Handle *ch;
37 struct GNUNET_PeerIdentity id; 37 struct GNUNET_PeerIdentity id;
38 struct GNUNET_TRANSPORT_Handle *th; 38 struct GNUNET_TRANSPORT_OfferHelloHandle *oh;
39 struct GNUNET_TRANSPORT_GetHelloHandle *ghh; 39 struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
40 struct GNUNET_ATS_ConnectivityHandle *ats; 40 struct GNUNET_ATS_ConnectivityHandle *ats;
41 struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh; 41 struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh;
@@ -56,6 +56,15 @@ static int ok;
56 56
57 57
58static void 58static void
59offer_hello_done (void *cls)
60{
61 struct PeerContext *p = cls;
62
63 p->oh = NULL;
64}
65
66
67static void
59process_hello (void *cls, 68process_hello (void *cls,
60 const struct GNUNET_MessageHeader *message) 69 const struct GNUNET_MessageHeader *message)
61{ 70{
@@ -64,10 +73,15 @@ process_hello (void *cls,
64 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 73 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
65 "Received (my) `%s' from transport service\n", "HELLO"); 74 "Received (my) `%s' from transport service\n", "HELLO");
66 GNUNET_assert (message != NULL); 75 GNUNET_assert (message != NULL);
67 if ((p == &p1) && (p2.th != NULL)) 76 if ((p == &p1) && (NULL == p2.oh))
68 GNUNET_TRANSPORT_offer_hello (p2.cfg, message, NULL, NULL); 77 p2.oh = GNUNET_TRANSPORT_offer_hello (p2.cfg, message,
69 if ((p == &p2) && (p1.th != NULL)) 78 &offer_hello_done,
70 GNUNET_TRANSPORT_offer_hello (p1.cfg, message, NULL, NULL); 79 &p2);
80 if ((p == &p2) && (NULL == p1.oh))
81 p1.oh = GNUNET_TRANSPORT_offer_hello (p1.cfg,
82 message,
83 &offer_hello_done,
84 &p1);
71} 85}
72 86
73 87
@@ -79,11 +93,15 @@ terminate_peer (struct PeerContext *p)
79 GNUNET_CORE_disconnect (p->ch); 93 GNUNET_CORE_disconnect (p->ch);
80 p->ch = NULL; 94 p->ch = NULL;
81 } 95 }
82 if (NULL != p->th) 96 if (NULL != p->ghh)
83 { 97 {
84 GNUNET_TRANSPORT_get_hello_cancel (p->ghh); 98 GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
85 GNUNET_TRANSPORT_disconnect (p->th); 99 p->ghh = NULL;
86 p->th = NULL; 100 }
101 if (NULL != p->oh)
102 {
103 GNUNET_TRANSPORT_offer_hello_cancel (p->oh);
104 p->oh = NULL;
87 } 105 }
88 if (NULL != p->ats_sh) 106 if (NULL != p->ats_sh)
89 { 107 {
@@ -276,8 +294,6 @@ setup_peer (struct PeerContext *p,
276 "gnunet-service-arm", 294 "gnunet-service-arm",
277 "-c", cfgname, NULL); 295 "-c", cfgname, NULL);
278 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 296 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
279 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
280 GNUNET_assert (NULL != p->th);
281 p->ats = GNUNET_ATS_connectivity_init (p->cfg); 297 p->ats = GNUNET_ATS_connectivity_init (p->cfg);
282 GNUNET_assert (NULL != p->ats); 298 GNUNET_assert (NULL != p->ats);
283 p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg, &process_hello, p); 299 p->ghh = GNUNET_TRANSPORT_get_hello (p->cfg, &process_hello, p);