diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-11-06 23:28:30 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-11-06 23:28:30 +0000 |
commit | 17bca33cca3c06668aa07c2750000a40a229c4a3 (patch) | |
tree | 70a1ad9c2506b4ca50b19fa0b387b46ab0b9b2e5 /src/transport/transport-testing.c | |
parent | bfe1f56580a066da971887c9beea44c890d26dd6 (diff) | |
download | gnunet-17bca33cca3c06668aa07c2750000a40a229c4a3.tar.gz gnunet-17bca33cca3c06668aa07c2750000a40a229c4a3.zip |
-removing last uses of TRANSPORT_try_connect API
Diffstat (limited to 'src/transport/transport-testing.c')
-rw-r--r-- | src/transport/transport-testing.c | 250 |
1 files changed, 165 insertions, 85 deletions
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index 86c67a039..a55727539 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c | |||
@@ -34,7 +34,6 @@ static struct PeerContext * | |||
34 | find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 34 | find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
35 | const struct GNUNET_PeerIdentity *peer) | 35 | const struct GNUNET_PeerIdentity *peer) |
36 | { | 36 | { |
37 | GNUNET_assert (tth != NULL); | ||
38 | struct PeerContext *t = tth->p_head; | 37 | struct PeerContext *t = tth->p_head; |
39 | 38 | ||
40 | while (t != NULL) | 39 | while (t != NULL) |
@@ -183,7 +182,8 @@ get_hello (void *cb_cls, | |||
183 | if (NULL != p->start_cb) | 182 | if (NULL != p->start_cb) |
184 | { | 183 | { |
185 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 184 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
186 | "Peer %u (`%s') successfully started\n", p->no, | 185 | "Peer %u (`%s') successfully started\n", |
186 | p->no, | ||
187 | GNUNET_i2s (&p->id)); | 187 | GNUNET_i2s (&p->id)); |
188 | p->start_cb (p, p->cb_cls); | 188 | p->start_cb (p, p->cb_cls); |
189 | p->start_cb = NULL; | 189 | p->start_cb = NULL; |
@@ -191,8 +191,43 @@ get_hello (void *cb_cls, | |||
191 | } | 191 | } |
192 | 192 | ||
193 | 193 | ||
194 | /** | ||
195 | * Offer the current HELLO of P2 to P1. | ||
196 | * | ||
197 | * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest ` | ||
198 | * @param tc scheduler context | ||
199 | */ | ||
200 | static void | ||
201 | offer_hello (void *cls, | ||
202 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
203 | |||
204 | |||
205 | /** | ||
206 | * Function called after the HELLO was passed to the | ||
207 | * transport service. | ||
208 | */ | ||
209 | static void | ||
210 | hello_offered (void *cls, | ||
211 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
212 | { | ||
213 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls; | ||
214 | |||
215 | cc->oh = NULL; | ||
216 | cc->tct = | ||
217 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
218 | &offer_hello, | ||
219 | cc); | ||
220 | } | ||
221 | |||
222 | |||
223 | /** | ||
224 | * Offer the current HELLO of P2 to P1. | ||
225 | * | ||
226 | * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest ` | ||
227 | * @param tc scheduler context | ||
228 | */ | ||
194 | static void | 229 | static void |
195 | try_connect (void *cls, | 230 | offer_hello (void *cls, |
196 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 231 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
197 | { | 232 | { |
198 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls; | 233 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls; |
@@ -202,26 +237,26 @@ try_connect (void *cls, | |||
202 | cc->tct = NULL; | 237 | cc->tct = NULL; |
203 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 238 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
204 | return; | 239 | return; |
240 | { | ||
241 | char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id)); | ||
205 | 242 | ||
206 | GNUNET_assert (cc != NULL); | 243 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
207 | GNUNET_assert (cc->p1 != NULL); | 244 | "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n", |
208 | GNUNET_assert (cc->p2 != NULL); | 245 | p1->no, |
209 | 246 | GNUNET_i2s (&p1->id), | |
210 | char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id)); | 247 | p2->no, |
211 | 248 | p2_s, | |
212 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 249 | GNUNET_HELLO_size (cc->p2->hello)); |
213 | "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n", | 250 | GNUNET_free (p2_s); |
214 | p1->no, GNUNET_i2s (&p1->id), p2->no, p2_s, | 251 | } |
215 | GNUNET_HELLO_size (cc->p2->hello)); | ||
216 | GNUNET_free (p2_s); | ||
217 | |||
218 | GNUNET_TRANSPORT_offer_hello (cc->th_p1, | ||
219 | (const struct GNUNET_MessageHeader *) cc-> | ||
220 | p2->hello, NULL, NULL); | ||
221 | GNUNET_TRANSPORT_try_connect (cc->th_p1, &p2->id, NULL, NULL); /*FIXME TRY_CONNECT change */ | ||
222 | 252 | ||
223 | cc->tct = | 253 | if (NULL != cc->oh) |
224 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, cc); | 254 | GNUNET_TRANSPORT_offer_hello_cancel (cc->oh); |
255 | cc->oh = | ||
256 | GNUNET_TRANSPORT_offer_hello (cc->p1->th, | ||
257 | (const struct GNUNET_MessageHeader *) cc->p2->hello, | ||
258 | &hello_offered, | ||
259 | cc); | ||
225 | } | 260 | } |
226 | 261 | ||
227 | 262 | ||
@@ -239,7 +274,8 @@ try_connect (void *cls, | |||
239 | */ | 274 | */ |
240 | struct PeerContext * | 275 | struct PeerContext * |
241 | GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 276 | GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
242 | const char *cfgname, int peer_id, | 277 | const char *cfgname, |
278 | int peer_id, | ||
243 | GNUNET_TRANSPORT_ReceiveCallback rec, | 279 | GNUNET_TRANSPORT_ReceiveCallback rec, |
244 | GNUNET_TRANSPORT_NotifyConnect nc, | 280 | GNUNET_TRANSPORT_NotifyConnect nc, |
245 | GNUNET_TRANSPORT_NotifyDisconnect nd, | 281 | GNUNET_TRANSPORT_NotifyDisconnect nd, |
@@ -278,7 +314,8 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth | |||
278 | 314 | ||
279 | p->no = peer_id; | 315 | p->no = peer_id; |
280 | /* Configure peer with configuration */ | 316 | /* Configure peer with configuration */ |
281 | p->peer = GNUNET_TESTING_peer_configure (tth->tl_system, p->cfg, p->no, NULL, &emsg); | 317 | p->peer = GNUNET_TESTING_peer_configure (tth->tl_system, |
318 | p->cfg, p->no, NULL, &emsg); | ||
282 | if (NULL == p->peer) | 319 | if (NULL == p->peer) |
283 | { | 320 | { |
284 | LOG (GNUNET_ERROR_TYPE_ERROR, | 321 | LOG (GNUNET_ERROR_TYPE_ERROR, |
@@ -329,41 +366,51 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth | |||
329 | 366 | ||
330 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, | 367 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, |
331 | ¬ify_receive, | 368 | ¬ify_receive, |
332 | ¬ify_connect, ¬ify_disconnect); | 369 | ¬ify_connect, |
370 | ¬ify_disconnect); | ||
333 | if (NULL == p->th) | 371 | if (NULL == p->th) |
334 | { | 372 | { |
335 | LOG (GNUNET_ERROR_TYPE_ERROR, | 373 | LOG (GNUNET_ERROR_TYPE_ERROR, |
336 | "Failed to connect to transport service for peer `%s': `%s'\n", | 374 | "Failed to connect to transport service for peer `%s': `%s'\n", |
337 | cfgname, | 375 | cfgname, |
338 | emsg); | 376 | emsg); |
339 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); | 377 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); |
340 | return NULL; | 378 | return NULL; |
341 | } | 379 | } |
342 | 380 | p->ats = GNUNET_ATS_connectivity_init (p->cfg); | |
343 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); | 381 | if (NULL == p->ats) |
382 | { | ||
383 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
384 | "Failed to connect to ATS service for peer `%s': `%s'\n", | ||
385 | cfgname, | ||
386 | emsg); | ||
387 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); | ||
388 | return NULL; | ||
389 | } | ||
390 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, | ||
391 | &get_hello, | ||
392 | p); | ||
344 | GNUNET_assert (p->ghh != NULL); | 393 | GNUNET_assert (p->ghh != NULL); |
345 | 394 | ||
346 | return p; | 395 | return p; |
347 | } | 396 | } |
348 | 397 | ||
398 | |||
349 | /** | 399 | /** |
350 | * Restart the given peer | 400 | * Restart the given peer |
351 | * @param tth testing handle | 401 | * |
352 | * @param p the peer | 402 | * @param p the peer |
353 | * @param cfgname the cfg file used to restart | 403 | * @param cfgname the cfg file used to restart |
354 | * @param restart_cb callback to call when restarted | 404 | * @param restart_cb callback to call when restarted |
355 | * @param cb_cls callback closure | 405 | * @param cb_cls callback closure |
356 | * @return GNUNET_OK in success otherwise GNUNET_SYSERR | 406 | * @return #GNUNET_OK in success otherwise #GNUNET_SYSERR |
357 | */ | 407 | */ |
358 | int | 408 | int |
359 | GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle | 409 | GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p, |
360 | *tth, struct PeerContext *p, | ||
361 | const char *cfgname, | 410 | const char *cfgname, |
362 | GNUNET_TRANSPORT_TESTING_start_cb | 411 | GNUNET_TRANSPORT_TESTING_start_cb restart_cb, |
363 | restart_cb, void *cb_cls) | 412 | void *cb_cls) |
364 | { | 413 | { |
365 | GNUNET_assert (tth != NULL); | ||
366 | GNUNET_assert (p != NULL); | ||
367 | GNUNET_assert (NULL != p->peer); | 414 | GNUNET_assert (NULL != p->peer); |
368 | 415 | ||
369 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 416 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -377,13 +424,22 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle | |||
377 | p->no, | 424 | p->no, |
378 | GNUNET_i2s (&p->id)); | 425 | GNUNET_i2s (&p->id)); |
379 | if (NULL != p->ghh) | 426 | if (NULL != p->ghh) |
427 | { | ||
380 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); | 428 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); |
381 | p->ghh = NULL; | 429 | p->ghh = NULL; |
382 | 430 | } | |
383 | if (NULL != p->th) | 431 | if (NULL != p->th) |
432 | { | ||
384 | GNUNET_TRANSPORT_disconnect (p->th); | 433 | GNUNET_TRANSPORT_disconnect (p->th); |
434 | p->th = NULL; | ||
435 | } | ||
436 | if (NULL != p->ats) | ||
437 | { | ||
438 | GNUNET_ATS_connectivity_done (p->ats); | ||
439 | p->ats = NULL; | ||
440 | } | ||
385 | 441 | ||
386 | if (GNUNET_SYSERR == GNUNET_TESTING_peer_stop(p->peer)) | 442 | if (GNUNET_SYSERR == GNUNET_TESTING_peer_stop (p->peer)) |
387 | { | 443 | { |
388 | LOG (GNUNET_ERROR_TYPE_ERROR, | 444 | LOG (GNUNET_ERROR_TYPE_ERROR, |
389 | "Failed to stop peer %u (`%s')\n", | 445 | "Failed to stop peer %u (`%s')\n", |
@@ -395,33 +451,38 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle | |||
395 | sleep (5); // YUCK! | 451 | sleep (5); // YUCK! |
396 | 452 | ||
397 | /* restart */ | 453 | /* restart */ |
398 | if (GNUNET_SYSERR == GNUNET_TESTING_peer_start(p->peer)) | 454 | if (GNUNET_SYSERR == GNUNET_TESTING_peer_start (p->peer)) |
399 | { | 455 | { |
400 | LOG (GNUNET_ERROR_TYPE_ERROR, | 456 | LOG (GNUNET_ERROR_TYPE_ERROR, |
401 | "Failed to restart peer %u (`%s')\n", | 457 | "Failed to restart peer %u (`%s')\n", |
402 | p->no, GNUNET_i2s (&p->id)); | 458 | p->no, |
459 | GNUNET_i2s (&p->id)); | ||
403 | return GNUNET_SYSERR; | 460 | return GNUNET_SYSERR; |
404 | } | 461 | } |
405 | 462 | ||
406 | GNUNET_assert (p->th != NULL); | 463 | GNUNET_assert (NULL == p->start_cb); |
407 | GNUNET_assert (p->start_cb == NULL); | ||
408 | p->start_cb = restart_cb; | 464 | p->start_cb = restart_cb; |
409 | p->cb_cls = cb_cls; | 465 | p->cb_cls = cb_cls; |
410 | 466 | ||
411 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, | 467 | p->th = GNUNET_TRANSPORT_connect (p->cfg, |
468 | NULL, | ||
469 | p, | ||
412 | ¬ify_receive, | 470 | ¬ify_receive, |
413 | ¬ify_connect, | 471 | ¬ify_connect, |
414 | ¬ify_disconnect); | 472 | ¬ify_disconnect); |
415 | GNUNET_assert (NULL != p->th); | 473 | GNUNET_assert (NULL != p->th); |
416 | 474 | p->ats = GNUNET_ATS_connectivity_init (p->cfg); | |
417 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); | 475 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, |
418 | GNUNET_assert (p->ghh != NULL); | 476 | &get_hello, |
477 | p); | ||
478 | GNUNET_assert (NULL != p->ghh); | ||
419 | return GNUNET_OK; | 479 | return GNUNET_OK; |
420 | } | 480 | } |
421 | 481 | ||
422 | 482 | ||
423 | /** | 483 | /** |
424 | * shutdown the given peer | 484 | * Shutdown the given peer |
485 | * | ||
425 | * @param tth testing handle | 486 | * @param tth testing handle |
426 | * @param p the peer | 487 | * @param p the peer |
427 | */ | 488 | */ |
@@ -429,19 +490,17 @@ void | |||
429 | GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 490 | GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
430 | struct PeerContext *p) | 491 | struct PeerContext *p) |
431 | { | 492 | { |
432 | GNUNET_assert (p != NULL); | 493 | if (NULL != p->ghh) |
433 | if (p->ghh != NULL) | ||
434 | { | 494 | { |
435 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); | 495 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); |
436 | p->ghh = NULL; | 496 | p->ghh = NULL; |
437 | } | 497 | } |
438 | if (p->th != NULL) | 498 | if (NULL != p->th) |
439 | { | 499 | { |
440 | GNUNET_TRANSPORT_disconnect (p->th); | 500 | GNUNET_TRANSPORT_disconnect (p->th); |
441 | p->th = NULL; | 501 | p->th = NULL; |
442 | } | 502 | } |
443 | 503 | if (NULL != p->peer) | |
444 | if (p->peer != NULL) | ||
445 | { | 504 | { |
446 | if (GNUNET_OK != GNUNET_TESTING_peer_stop (p->peer)) | 505 | if (GNUNET_OK != GNUNET_TESTING_peer_stop (p->peer)) |
447 | { | 506 | { |
@@ -452,20 +511,27 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
452 | GNUNET_TESTING_peer_destroy (p->peer); | 511 | GNUNET_TESTING_peer_destroy (p->peer); |
453 | p->peer = NULL; | 512 | p->peer = NULL; |
454 | } | 513 | } |
455 | 514 | if (NULL != p->ats) | |
456 | if (p->hello != NULL) | 515 | { |
516 | GNUNET_ATS_connectivity_done (p->ats); | ||
517 | p->ats = NULL; | ||
518 | } | ||
519 | if (NULL != p->hello) | ||
457 | { | 520 | { |
458 | GNUNET_free (p->hello); | 521 | GNUNET_free (p->hello); |
459 | p->hello = NULL; | 522 | p->hello = NULL; |
460 | } | 523 | } |
461 | if (p->cfg != NULL) | 524 | if (NULL != p->cfg) |
462 | { | 525 | { |
463 | GNUNET_CONFIGURATION_destroy (p->cfg); | 526 | GNUNET_CONFIGURATION_destroy (p->cfg); |
464 | p->cfg = NULL; | 527 | p->cfg = NULL; |
465 | } | 528 | } |
466 | GNUNET_CONTAINER_DLL_remove (tth->p_head, tth->p_tail, p); | 529 | GNUNET_CONTAINER_DLL_remove (tth->p_head, |
530 | tth->p_tail, | ||
531 | p); | ||
467 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 532 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
468 | "Peer %u (`%s') stopped \n", p->no, | 533 | "Peer %u (`%s') stopped \n", |
534 | p->no, | ||
469 | GNUNET_i2s (&p->id)); | 535 | GNUNET_i2s (&p->id)); |
470 | GNUNET_free (p); | 536 | GNUNET_free (p); |
471 | } | 537 | } |
@@ -490,26 +556,25 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * | |||
490 | GNUNET_TRANSPORT_TESTING_connect_cb cb, | 556 | GNUNET_TRANSPORT_TESTING_connect_cb cb, |
491 | void *cls) | 557 | void *cls) |
492 | { | 558 | { |
493 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest); | 559 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc; |
494 | 560 | ||
495 | GNUNET_assert (tth != NULL); | 561 | cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest); |
496 | GNUNET_assert (p1 != NULL); | ||
497 | GNUNET_assert (p2 != NULL); | ||
498 | cc->p1 = p1; | 562 | cc->p1 = p1; |
499 | cc->p2 = p2; | 563 | cc->p2 = p2; |
500 | cc->cb = cb; | 564 | cc->cb = cb; |
501 | if (cls != NULL) | 565 | if (NULL != cls) |
502 | cc->cb_cls = cls; | 566 | cc->cb_cls = cls; |
503 | else | 567 | else |
504 | cc->cb_cls = cc; | 568 | cc->cb_cls = cc; |
505 | cc->th_p1 = p1->th; | ||
506 | cc->th_p2 = p2->th; | ||
507 | GNUNET_assert (cc->th_p1 != NULL); | ||
508 | GNUNET_assert (cc->th_p2 != NULL); | ||
509 | GNUNET_CONTAINER_DLL_insert (tth->cc_head, | 569 | GNUNET_CONTAINER_DLL_insert (tth->cc_head, |
510 | tth->cc_tail, | 570 | tth->cc_tail, |
511 | cc); | 571 | cc); |
512 | cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc); | 572 | cc->tct = GNUNET_SCHEDULER_add_now (&offer_hello, |
573 | cc); | ||
574 | cc->ats_sh = GNUNET_ATS_connectivity_suggest (cc->p1->ats, | ||
575 | &p2->id, | ||
576 | 1); | ||
577 | |||
513 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 578 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
514 | "New connect request %p\n", | 579 | "New connect request %p\n", |
515 | cc); | 580 | cc); |
@@ -529,17 +594,28 @@ void | |||
529 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 594 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
530 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc) | 595 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc) |
531 | { | 596 | { |
532 | GNUNET_assert (tth != NULL); | ||
533 | |||
534 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 597 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
535 | "Canceling connect request %p!\n", | 598 | "Canceling connect request %p!\n", |
536 | cc); | 599 | cc); |
537 | 600 | if (NULL != cc->tct) | |
538 | if (cc->tct != NULL) | 601 | { |
539 | GNUNET_SCHEDULER_cancel (cc->tct); | 602 | GNUNET_SCHEDULER_cancel (cc->tct); |
540 | cc->tct = NULL; | 603 | cc->tct = NULL; |
604 | } | ||
605 | if (NULL != cc->oh) | ||
606 | { | ||
607 | GNUNET_TRANSPORT_offer_hello_cancel (cc->oh); | ||
608 | cc->oh = NULL; | ||
609 | } | ||
610 | if (NULL != cc->ats_sh) | ||
611 | { | ||
612 | GNUNET_ATS_connectivity_suggest_cancel (cc->ats_sh); | ||
613 | cc->ats_sh = NULL; | ||
614 | } | ||
541 | 615 | ||
542 | GNUNET_CONTAINER_DLL_remove (tth->cc_head, tth->cc_tail, cc); | 616 | GNUNET_CONTAINER_DLL_remove (tth->cc_head, |
617 | tth->cc_tail, | ||
618 | cc); | ||
543 | GNUNET_free (cc); | 619 | GNUNET_free (cc); |
544 | } | 620 | } |
545 | 621 | ||
@@ -556,19 +632,18 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth) | |||
556 | struct PeerContext *p = tth->p_head; | 632 | struct PeerContext *p = tth->p_head; |
557 | struct PeerContext *t = NULL; | 633 | struct PeerContext *t = NULL; |
558 | 634 | ||
559 | GNUNET_assert (tth != NULL); | ||
560 | |||
561 | while (cc != tth->cc_tail) | 635 | while (cc != tth->cc_tail) |
562 | { | 636 | { |
563 | ct = cc->next; | 637 | ct = cc->next; |
564 | LOG (GNUNET_ERROR_TYPE_ERROR, | 638 | LOG (GNUNET_ERROR_TYPE_ERROR, |
565 | "Developer forgot to cancel connect request %p!\n", | 639 | "Developer forgot to cancel connect request %p!\n", |
566 | cc); | 640 | cc); |
567 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); | 641 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, |
642 | cc); | ||
568 | cc = ct; | 643 | cc = ct; |
569 | } | 644 | } |
570 | 645 | ||
571 | while (p != NULL) | 646 | while (NULL != p) |
572 | { | 647 | { |
573 | t = p->next; | 648 | t = p->next; |
574 | LOG (GNUNET_ERROR_TYPE_ERROR, | 649 | LOG (GNUNET_ERROR_TYPE_ERROR, |
@@ -577,7 +652,8 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth) | |||
577 | p = t; | 652 | p = t; |
578 | } | 653 | } |
579 | 654 | ||
580 | GNUNET_TESTING_system_destroy (tth->tl_system, GNUNET_YES); | 655 | GNUNET_TESTING_system_destroy (tth->tl_system, |
656 | GNUNET_YES); | ||
581 | 657 | ||
582 | GNUNET_free (tth); | 658 | GNUNET_free (tth); |
583 | tth = NULL; | 659 | tth = NULL; |
@@ -619,6 +695,7 @@ GNUNET_TRANSPORT_TESTING_init () | |||
619 | 695 | ||
620 | /** | 696 | /** |
621 | * Removes all directory separators from absolute filename | 697 | * Removes all directory separators from absolute filename |
698 | * | ||
622 | * @param file the absolute file name, e.g. as found in argv[0] | 699 | * @param file the absolute file name, e.g. as found in argv[0] |
623 | * @return extracted file name, has to be freed by caller | 700 | * @return extracted file name, has to be freed by caller |
624 | */ | 701 | */ |
@@ -670,7 +747,9 @@ extract_filename (const char *file) | |||
670 | 747 | ||
671 | 748 | ||
672 | /** | 749 | /** |
673 | * Extracts the test filename from an absolute file name and removes the extension | 750 | * Extracts the test filename from an absolute file name and removes |
751 | * the extension | ||
752 | * | ||
674 | * @param file absolute file name | 753 | * @param file absolute file name |
675 | * @param dest where to store result | 754 | * @param dest where to store result |
676 | */ | 755 | */ |
@@ -709,6 +788,7 @@ suc: | |||
709 | 788 | ||
710 | /** | 789 | /** |
711 | * Extracts the filename from an absolute file name and removes the extension | 790 | * Extracts the filename from an absolute file name and removes the extension |
791 | * | ||
712 | * @param file absolute file name | 792 | * @param file absolute file name |
713 | * @param dest where to store result | 793 | * @param dest where to store result |
714 | */ | 794 | */ |