aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-09-14 12:46:50 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-09-14 12:46:50 +0000
commit929da264a0eb0375c4eab1bb64794137b246451d (patch)
tree2038c59aeb9ad5dc2754d3314731b31d8ce2b96d /src/testbed
parent0f4b7b7fb04e1af1810e3414cdeb3881d8465999 (diff)
downloadgnunet-929da264a0eb0375c4eab1bb64794137b246451d.tar.gz
gnunet-929da264a0eb0375c4eab1bb64794137b246451d.zip
stop peers before destroying
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/gnunet-service-testbed.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index 6df2992f0..fd8600598 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -185,24 +185,24 @@ struct Slave
185 */ 185 */
186enum LCFContextState 186enum LCFContextState
187{ 187{
188 /** 188 /**
189 * The Context has been initialized; Nothing has been done on it 189 * The Context has been initialized; Nothing has been done on it
190 */ 190 */
191 INIT, 191 INIT,
192 192
193 /** 193 /**
194 * Delegated host has been registered at the forwarding controller 194 * Delegated host has been registered at the forwarding controller
195 */ 195 */
196 DELEGATED_HOST_REGISTERED, 196 DELEGATED_HOST_REGISTERED,
197 197
198 /** 198 /**
199 * The slave host has been registred at the forwarding controller 199 * The slave host has been registred at the forwarding controller
200 */ 200 */
201 SLAVE_HOST_REGISTERED, 201 SLAVE_HOST_REGISTERED,
202 202
203 /** 203 /**
204 * The context has been finished (may have error) 204 * The context has been finished (may have error)
205 */ 205 */
206 FINISHED 206 FINISHED
207}; 207};
208 208
@@ -296,6 +296,11 @@ struct Peer
296 * peer is configured with 296 * peer is configured with
297 */ 297 */
298 struct GNUNET_CONFIGURATION_Handle *cfg; 298 struct GNUNET_CONFIGURATION_Handle *cfg;
299
300 /**
301 * Is the peer running
302 */
303 int is_running;
299 304
300 } local; 305 } local;
301 306
@@ -311,14 +316,14 @@ struct Peer
311 } details; 316 } details;
312 317
313 /** 318 /**
314 * Our local reference id for this peer 319 * Is this peer local created?
315 */ 320 */
316 uint32_t id; 321 int is_remote;
317 322
318 /** 323 /**
319 * Is this peer local created? 324 * Our local reference id for this peer
320 */ 325 */
321 uint32_t is_remote; 326 uint32_t id;
322 327
323}; 328};
324 329
@@ -1646,6 +1651,7 @@ handle_peer_create (void *cls, struct GNUNET_SERVER_Client *client,
1646 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1651 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1647 return; 1652 return;
1648 } 1653 }
1654 peer->details.local.is_running = GNUNET_NO;
1649 peer_list_add (peer); 1655 peer_list_add (peer);
1650 reply = 1656 reply =
1651 GNUNET_malloc (sizeof 1657 GNUNET_malloc (sizeof
@@ -1796,6 +1802,7 @@ handle_peer_start (void *cls, struct GNUNET_SERVER_Client *client,
1796 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1802 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1797 return; 1803 return;
1798 } 1804 }
1805 peer->details.local.is_running = GNUNET_YES;
1799 reply = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerEventMessage)); 1806 reply = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerEventMessage));
1800 reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT); 1807 reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT);
1801 reply->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerEventMessage)); 1808 reply->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerEventMessage));
@@ -1859,6 +1866,7 @@ handle_peer_stop (void *cls, struct GNUNET_SERVER_Client *client,
1859 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1866 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1860 return; 1867 return;
1861 } 1868 }
1869 peer->details.local.is_running = GNUNET_NO;
1862 reply = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerEventMessage)); 1870 reply = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerEventMessage));
1863 reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT); 1871 reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT);
1864 reply->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerEventMessage)); 1872 reply->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerEventMessage));
@@ -2207,12 +2215,13 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client,
2207 GNUNET_assert (NULL != peer_list[p2]); 2215 GNUNET_assert (NULL != peer_list[p2]);
2208 /* FIXME: Add cases where we have to forward overlay connect message to sub 2216 /* FIXME: Add cases where we have to forward overlay connect message to sub
2209 * controllers */ 2217 * controllers */
2218 GNUNET_assert (GNUNET_NO == peer_list[p1]->is_remote);
2210 occ = GNUNET_malloc (sizeof (struct OverlayConnectContext)); 2219 occ = GNUNET_malloc (sizeof (struct OverlayConnectContext));
2211 GNUNET_SERVER_client_keep (client); 2220 GNUNET_SERVER_client_keep (client);
2212 occ->client = client; 2221 occ->client = client;
2213 occ->peer = peer_list[p1]; 2222 occ->peer = peer_list[p1];
2214 occ->other_peer = peer_list[p2]; 2223 occ->other_peer = peer_list[p2];
2215 occ->op_id = GNUNET_ntohll (msg->operation_id); 2224 occ->op_id = GNUNET_ntohll (msg->operation_id);
2216 /* Connect to the core of 1st peer and wait for the 2nd peer to connect */ 2225 /* Connect to the core of 1st peer and wait for the 2nd peer to connect */
2217 occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE"); 2226 occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE");
2218 occ->ch = 2227 occ->ch =
@@ -2295,6 +2304,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2295 { 2304 {
2296 if (GNUNET_NO == peer_list[id]->is_remote) 2305 if (GNUNET_NO == peer_list[id]->is_remote)
2297 { 2306 {
2307 if (GNUNET_YES == peer_list[id]->details.local.is_running)
2308 GNUNET_TESTING_peer_stop (peer_list[id]->details.local.peer);
2298 GNUNET_TESTING_peer_destroy (peer_list[id]->details.local.peer); 2309 GNUNET_TESTING_peer_destroy (peer_list[id]->details.local.peer);
2299 GNUNET_CONFIGURATION_destroy (peer_list[id]->details.local.cfg); 2310 GNUNET_CONFIGURATION_destroy (peer_list[id]->details.local.cfg);
2300 } 2311 }