aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport-testing2.c')
-rw-r--r--src/transport/transport-testing2.c83
1 files changed, 46 insertions, 37 deletions
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index d553a3961..eaa8a5f15 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -328,6 +328,8 @@ notify_disconnect (void *cls,
328 } 328 }
329} 329}
330 330
331static void
332retrieve_hello (void *cls);
331 333
332static void 334static void
333hello_iter_cb (void *cb_cls, 335hello_iter_cb (void *cb_cls,
@@ -338,14 +340,15 @@ hello_iter_cb (void *cb_cls,
338 if ((NULL == record) && (NULL == emsg)) 340 if ((NULL == record) && (NULL == emsg))
339 { 341 {
340 p->pic = NULL; 342 p->pic = NULL;
341 LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration End\n"); 343 if (NULL != p->start_cb)
344 p->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, p);
342 return; 345 return;
343 } 346 }
344 //Check record type et al? 347 // Check record type et al?
345 p->hello_size = record->value_size; 348 p->hello_size = record->value_size;
346 p->hello = GNUNET_malloc (p->hello_size); 349 p->hello = GNUNET_malloc (p->hello_size);
347 memcpy (p->hello, record->value, p->hello_size); 350 memcpy (p->hello, record->value, p->hello_size);
348 p->hello[p->hello_size-1] = '\0'; 351 p->hello[p->hello_size - 1] = '\0';
349 352
350 GNUNET_PEERSTORE_iterate_cancel (p->pic); 353 GNUNET_PEERSTORE_iterate_cancel (p->pic);
351 p->pic = NULL; 354 p->pic = NULL;
@@ -360,13 +363,12 @@ hello_iter_cb (void *cb_cls,
360 } 363 }
361} 364}
362 365
366
363static void 367static void
364retrieve_hello(void *cls) 368retrieve_hello (void *cls)
365{ 369{
366 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls; 370 struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
367 LOG (GNUNET_ERROR_TYPE_DEBUG, 371 p->rh_task = NULL;
368 "Getting hello...\n");
369
370 p->pic = GNUNET_PEERSTORE_iterate (p->ph, 372 p->pic = GNUNET_PEERSTORE_iterate (p->ph,
371 "transport", 373 "transport",
372 &p->id, 374 &p->id,
@@ -377,7 +379,6 @@ retrieve_hello(void *cls)
377} 379}
378 380
379 381
380
381/** 382/**
382 * Start a peer with the given configuration 383 * Start a peer with the given configuration
383 * @param tth the testing handle 384 * @param tth the testing handle
@@ -535,11 +536,8 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct
535 // FIXME Error handling 536 // FIXME Error handling
536 p->ah = GNUNET_TRANSPORT_application_init (p->cfg); 537 p->ah = GNUNET_TRANSPORT_application_init (p->cfg);
537 GNUNET_assert (NULL != p->ah); 538 GNUNET_assert (NULL != p->ah);
538 // FIXME Error handleing 539 // FIXME Error handling
539 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), 540 p->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, p);
540 retrieve_hello,
541 p);
542 //GNUNET_assert (NULL != p->pic);
543 541
544 return p; 542 return p;
545} 543}
@@ -650,6 +648,11 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
650 struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth; 648 struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
651 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc; 649 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
652 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ccn; 650 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ccn;
651 /* shutdown */
652 LOG (GNUNET_ERROR_TYPE_DEBUG,
653 "Stopping peer %u (`%s')\n",
654 p->no,
655 GNUNET_i2s (&p->id));
653 656
654 for (cc = tth->cc_head; NULL != cc; cc = ccn) 657 for (cc = tth->cc_head; NULL != cc; cc = ccn)
655 { 658 {
@@ -660,7 +663,7 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
660 } 663 }
661 if (NULL != p->pic) 664 if (NULL != p->pic)
662 { 665 {
663 //GNUNET_PEERSTORE_iterate_cancel (p->pic); 666 GNUNET_PEERSTORE_iterate_cancel (p->pic);
664 p->pic = NULL; 667 p->pic = NULL;
665 } 668 }
666 if (NULL != p->th) 669 if (NULL != p->th)
@@ -668,19 +671,6 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
668 GNUNET_TRANSPORT_core_disconnect (p->th); 671 GNUNET_TRANSPORT_core_disconnect (p->th);
669 p->th = NULL; 672 p->th = NULL;
670 } 673 }
671 if (NULL != p->peer)
672 {
673 if (GNUNET_OK !=
674 GNUNET_TESTING_peer_stop (p->peer))
675 {
676 LOG (GNUNET_ERROR_TYPE_DEBUG,
677 "Testing lib failed to stop peer %u (`%s')\n",
678 p->no,
679 GNUNET_i2s (&p->id));
680 }
681 GNUNET_TESTING_peer_destroy (p->peer);
682 p->peer = NULL;
683 }
684 if (NULL != p->ats) 674 if (NULL != p->ats)
685 { 675 {
686 GNUNET_ATS_connectivity_done (p->ats); 676 GNUNET_ATS_connectivity_done (p->ats);
@@ -693,9 +683,25 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
693 } 683 }
694 if (NULL != p->ph) 684 if (NULL != p->ph)
695 { 685 {
686 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
687 "Disconnecting from PEERSTORE service\n");
696 GNUNET_PEERSTORE_disconnect (p->ph, GNUNET_NO); 688 GNUNET_PEERSTORE_disconnect (p->ph, GNUNET_NO);
697 p->ph = NULL; 689 p->ph = NULL;
698 } 690 }
691
692 if (NULL != p->peer)
693 {
694 if (GNUNET_OK !=
695 GNUNET_TESTING_peer_stop (p->peer))
696 {
697 LOG (GNUNET_ERROR_TYPE_DEBUG,
698 "Testing lib failed to stop peer %u (`%s')\n",
699 p->no,
700 GNUNET_i2s (&p->id));
701 }
702 GNUNET_TESTING_peer_destroy (p->peer);
703 p->peer = NULL;
704 }
699 if (NULL != p->hello) 705 if (NULL != p->hello)
700 { 706 {
701 GNUNET_free (p->hello); 707 GNUNET_free (p->hello);
@@ -718,6 +724,9 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
718 "Peer %u (`%s') stopped\n", 724 "Peer %u (`%s') stopped\n",
719 p->no, 725 p->no,
720 GNUNET_i2s (&p->id)); 726 GNUNET_i2s (&p->id));
727 if (NULL != p->rh_task)
728 GNUNET_SCHEDULER_cancel (p->rh_task);
729 p->rh_task = NULL;
721 GNUNET_free (p); 730 GNUNET_free (p);
722} 731}
723 732
@@ -728,16 +737,16 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
728 * FIXME maybe schedule the application_validate somehow 737 * FIXME maybe schedule the application_validate somehow
729 */ 738 */
730/* 739/*
731static void 740 static void
732hello_offered (void *cls) 741 hello_offered (void *cls)
733{ 742 {
734 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls; 743 struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls;
735 744
736 cc->oh = NULL; 745 cc->oh = NULL;
737 cc->tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 746 cc->tct = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
738 &offer_hello, 747 &offer_hello,
739 cc); 748 cc);
740}*/ 749 }*/
741 750
742 751
743/** 752/**