diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-14 17:16:02 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-14 17:16:02 +0000 |
commit | 5db5fe8fc0cb0d2798a83b20436862f29cb308c8 (patch) | |
tree | ddd700e28beed6ac16c5e71711bd8f50fd55a8c2 /src | |
parent | ff3a1b36c6e34afd03d13f05e9c0b8eeccf0a87d (diff) | |
download | gnunet-5db5fe8fc0cb0d2798a83b20436862f29cb308c8.tar.gz gnunet-5db5fe8fc0cb0d2798a83b20436862f29cb308c8.zip |
fix crash on shutdown
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/test_transport_api_monitoring.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/transport/test_transport_api_monitoring.c b/src/transport/test_transport_api_monitoring.c index d06ac6381..f726344dd 100644 --- a/src/transport/test_transport_api_monitoring.c +++ b/src/transport/test_transport_api_monitoring.c | |||
@@ -84,6 +84,9 @@ static int p1_c = GNUNET_NO; | |||
84 | 84 | ||
85 | static int p2_c = GNUNET_NO; | 85 | static int p2_c = GNUNET_NO; |
86 | 86 | ||
87 | static int p1_c_notify = GNUNET_NO; | ||
88 | |||
89 | static int p2_c_notify = GNUNET_NO; | ||
87 | 90 | ||
88 | static void | 91 | static void |
89 | end () | 92 | end () |
@@ -101,6 +104,11 @@ end () | |||
101 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 104 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
102 | th = NULL; | 105 | th = NULL; |
103 | 106 | ||
107 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | ||
108 | p1 = NULL; | ||
109 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | ||
110 | p2 = NULL; | ||
111 | |||
104 | if (NULL != pmc_p1) | 112 | if (NULL != pmc_p1) |
105 | { | 113 | { |
106 | GNUNET_TRANSPORT_monitor_peers_cancel (pmc_p1); | 114 | GNUNET_TRANSPORT_monitor_peers_cancel (pmc_p1); |
@@ -112,10 +120,7 @@ end () | |||
112 | pmc_p2 = NULL; | 120 | pmc_p2 = NULL; |
113 | } | 121 | } |
114 | 122 | ||
115 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 123 | |
116 | p1 = NULL; | ||
117 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | ||
118 | p2 = NULL; | ||
119 | 124 | ||
120 | ok = 0; | 125 | ok = 0; |
121 | } | 126 | } |
@@ -265,6 +270,16 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
265 | p1); | 270 | p1); |
266 | } | 271 | } |
267 | 272 | ||
273 | static void done () | ||
274 | { | ||
275 | if ((GNUNET_YES == p1_c) && (GNUNET_YES == p2_c) && p1_c_notify && p2_c_notify) | ||
276 | { | ||
277 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Both peers state to be connected\n"); | ||
278 | ok = 0; | ||
279 | end(); | ||
280 | } | ||
281 | } | ||
282 | |||
268 | 283 | ||
269 | static void | 284 | static void |
270 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 285 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) |
@@ -276,9 +291,15 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
276 | struct PeerContext *t = NULL; | 291 | struct PeerContext *t = NULL; |
277 | 292 | ||
278 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) | 293 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) |
294 | { | ||
295 | p1_c_notify = GNUNET_YES; | ||
279 | t = p1; | 296 | t = p1; |
297 | } | ||
280 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) | 298 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) |
299 | { | ||
300 | p2_c_notify = GNUNET_YES; | ||
281 | t = p2; | 301 | t = p2; |
302 | } | ||
282 | GNUNET_assert (t != NULL); | 303 | GNUNET_assert (t != NULL); |
283 | 304 | ||
284 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 305 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); |
@@ -286,6 +307,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
286 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 307 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
287 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, | 308 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, |
288 | t->no, GNUNET_i2s (peer)); | 309 | t->no, GNUNET_i2s (peer)); |
310 | if (p1_c_notify && p2_c_notify) | ||
311 | GNUNET_SCHEDULER_add_now(&done, NULL); | ||
289 | GNUNET_free (ps); | 312 | GNUNET_free (ps); |
290 | } | 313 | } |
291 | 314 | ||
@@ -349,15 +372,6 @@ start_cb (struct PeerContext *p, void *cls) | |||
349 | 372 | ||
350 | } | 373 | } |
351 | 374 | ||
352 | static void done () | ||
353 | { | ||
354 | if ((GNUNET_YES == p1_c) && (GNUNET_YES == p2_c)) | ||
355 | { | ||
356 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Both peers state to be connected\n"); | ||
357 | ok = 0; | ||
358 | end(); | ||
359 | } | ||
360 | } | ||
361 | 375 | ||
362 | static void monitor1_cb (void *cls, | 376 | static void monitor1_cb (void *cls, |
363 | const struct GNUNET_PeerIdentity *peer, | 377 | const struct GNUNET_PeerIdentity *peer, |