aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-01-07 16:46:41 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-01-07 16:46:41 +0000
commit8c3b09fae9816ac88823d2f450c46cfe6a9c33c8 (patch)
treed0b5745b45c6706b2b467b44eabd8c64f9f7b3cd /src/gns
parenteb0d78ddbb8884c441a3467df62659be27384056 (diff)
downloadgnunet-8c3b09fae9816ac88823d2f450c46cfe6a9c33c8.tar.gz
gnunet-8c3b09fae9816ac88823d2f450c46cfe6a9c33c8.zip
- use GNUNET_TESTBED_overlay_configure_topology(); simplifies and also ensures that overlay connect operations continue when they are done 1 at a time.
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/test_gns_dht_three_peers.c76
1 files changed, 16 insertions, 60 deletions
diff --git a/src/gns/test_gns_dht_three_peers.c b/src/gns/test_gns_dht_three_peers.c
index df31250e7..5c4e54e13 100644
--- a/src/gns/test_gns_dht_three_peers.c
+++ b/src/gns/test_gns_dht_three_peers.c
@@ -71,7 +71,7 @@ static struct GNUNET_GNS_Handle *gh;
71static struct GNUNET_GNS_LookupRequest *lookup_handle; 71static struct GNUNET_GNS_LookupRequest *lookup_handle;
72 72
73static struct GNUNET_TESTBED_Operation *get_cfg_ops[3]; 73static struct GNUNET_TESTBED_Operation *get_cfg_ops[3];
74static struct GNUNET_TESTBED_Operation *connect_ops[3]; 74static struct GNUNET_TESTBED_Operation *topology_op;
75static struct GNUNET_CONFIGURATION_Handle *cfg_handles[3]; 75static struct GNUNET_CONFIGURATION_Handle *cfg_handles[3];
76static struct GNUNET_NAMESTORE_Handle *nh[3]; 76static struct GNUNET_NAMESTORE_Handle *nh[3];
77 77
@@ -109,18 +109,17 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
109 GNUNET_TESTBED_operation_done(get_cfg_ops[c]); 109 GNUNET_TESTBED_operation_done(get_cfg_ops[c]);
110 get_cfg_ops[c] = NULL; 110 get_cfg_ops[c] = NULL;
111 } 111 }
112 if (NULL != connect_ops[c])
113 {
114 GNUNET_TESTBED_operation_done(connect_ops[c]);
115 connect_ops[c] = NULL;
116 }
117 if (NULL != cfg_handles[c]) 112 if (NULL != cfg_handles[c])
118 { 113 {
119 GNUNET_CONFIGURATION_destroy (cfg_handles[c]); 114 GNUNET_CONFIGURATION_destroy (cfg_handles[c]);
120 cfg_handles[c] = NULL; 115 cfg_handles[c] = NULL;
121 } 116 }
122 } 117 }
123 118 if (NULL != topology_op)
119 {
120 GNUNET_TESTBED_operation_done (topology_op);
121 topology_op = NULL;
122 }
124 if (NULL != lookup_handle) 123 if (NULL != lookup_handle)
125 { 124 {
126 GNUNET_GNS_cancel_lookup_request (lookup_handle); 125 GNUNET_GNS_cancel_lookup_request (lookup_handle);
@@ -181,27 +180,11 @@ setup_end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
181 setup_task = GNUNET_SCHEDULER_NO_TASK; 180 setup_task = GNUNET_SCHEDULER_NO_TASK;
182 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout during setup, test failed\n"); 181 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout during setup, test failed\n");
183 182
184 if (NULL != connect_ops[0]) 183 if (NULL != topology_op)
185 {
186 GNUNET_TESTBED_operation_done (connect_ops[0]);
187 connect_ops[0] = NULL;
188 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect peer 0 and 1\n");
189 }
190
191 if (NULL != connect_ops[1])
192 {
193 GNUNET_TESTBED_operation_done (connect_ops[1]);
194 connect_ops[1] = NULL;
195 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect peer 1 and 2\n");
196 }
197
198 if (NULL != connect_ops[2])
199 { 184 {
200 GNUNET_TESTBED_operation_done (connect_ops[2]); 185 GNUNET_TESTBED_operation_done (topology_op);
201 connect_ops[2] = NULL; 186 topology_op = NULL;
202 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect peer 0 and 2\n");
203 } 187 }
204
205 GNUNET_SCHEDULER_shutdown (); 188 GNUNET_SCHEDULER_shutdown ();
206 ok = GNUNET_SYSERR; 189 ok = GNUNET_SYSERR;
207} 190}
@@ -312,17 +295,11 @@ static void connect_peers ()
312 { 295 {
313 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started\n"); 296 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started\n");
314 297
315 connect_ops[0] = GNUNET_TESTBED_overlay_connect (NULL, NULL, NULL, 298 topology_op =
316 cpeers[0], 299 GNUNET_TESTBED_overlay_configure_topology (NULL, 3, cpeers,
317 cpeers[1]); 300 NULL,
318 301 GNUNET_TESTBED_TOPOLOGY_RING,
319 connect_ops[1] = GNUNET_TESTBED_overlay_connect (NULL, NULL, NULL, 302 GNUNET_TESTBED_TOPOLOGY_OPTION_END);
320 cpeers[1],
321 cpeers[2]);
322
323 connect_ops[2] = GNUNET_TESTBED_overlay_connect (NULL, NULL, NULL,
324 cpeers[0],
325 cpeers[2]);
326 } 303 }
327} 304}
328 305
@@ -647,32 +624,11 @@ void testbed_controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformat
647 break; 624 break;
648 case GNUNET_TESTBED_ET_CONNECT: 625 case GNUNET_TESTBED_ET_CONNECT:
649 connections ++; 626 connections ++;
650 if ((event->details.peer_connect.peer1 == cpeers[0]) &&
651 (event->details.peer_connect.peer2 == cpeers[1]))
652 {
653 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 0 and 1 are connected\n");
654 GNUNET_TESTBED_operation_done (connect_ops[0]);
655 connect_ops[0] = NULL;
656 }
657
658 if ((event->details.peer_connect.peer1 == cpeers[1]) &&
659 (event->details.peer_connect.peer2 == cpeers[2]))
660 {
661 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 and 2 are connected\n");
662 GNUNET_TESTBED_operation_done (connect_ops[1]);
663 connect_ops[1] = NULL;
664 }
665
666 if ((event->details.peer_connect.peer1 == cpeers[0]) &&
667 (event->details.peer_connect.peer2 == cpeers[2]))
668 {
669 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 0 and 2 are connected\n");
670 GNUNET_TESTBED_operation_done (connect_ops[2]);
671 connect_ops[2] = NULL;
672 }
673 if (connections == 3) 627 if (connections == 3)
674 { 628 {
675 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers connected\n"); 629 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers connected\n");
630 GNUNET_TESTBED_operation_done (topology_op);
631 topology_op = NULL;
676 all_connected (); 632 all_connected ();
677 } 633 }
678 break; 634 break;