diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-03-28 12:05:37 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-03-28 12:05:37 +0000 |
commit | f1a6f1b56d25ac17f5486f48576cb2accd49c97e (patch) | |
tree | 022a7ad54cc53d3f145d6c125151c47c5c9e05ef /src | |
parent | 77b9205f561d168d7be860676144a47997014907 (diff) | |
download | gnunet-f1a6f1b56d25ac17f5486f48576cb2accd49c97e.tar.gz gnunet-f1a6f1b56d25ac17f5486f48576cb2accd49c97e.zip |
- fix DLL removals while cleaning up operation contexts
Diffstat (limited to 'src')
-rw-r--r-- | src/testbed/testbed_api.c | 22 | ||||
-rw-r--r-- | src/testbed/testbed_api_peers.c | 72 |
2 files changed, 54 insertions, 40 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 6bed65cee..25ed1ab41 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c | |||
@@ -532,8 +532,7 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c, | |||
532 | return GNUNET_YES; | 532 | return GNUNET_YES; |
533 | } | 533 | } |
534 | GNUNET_assert (OP_OVERLAY_CONNECT == opc->type); | 534 | GNUNET_assert (OP_OVERLAY_CONNECT == opc->type); |
535 | data = opc->data; | 535 | GNUNET_assert (NULL != (data = opc->data)); |
536 | GNUNET_assert (NULL != data); | ||
537 | GNUNET_assert ((ntohl (msg->peer1) == data->p1->unique_id) && | 536 | GNUNET_assert ((ntohl (msg->peer1) == data->p1->unique_id) && |
538 | (ntohl (msg->peer2) == data->p2->unique_id)); | 537 | (ntohl (msg->peer2) == data->p2->unique_id)); |
539 | event.type = (enum GNUNET_TESTBED_EventType) ntohl (msg->event_type); | 538 | event.type = (enum GNUNET_TESTBED_EventType) ntohl (msg->event_type); |
@@ -815,8 +814,6 @@ handle_slave_config (struct GNUNET_TESTBED_Controller *c, | |||
815 | GNUNET_break (0); | 814 | GNUNET_break (0); |
816 | return GNUNET_YES; | 815 | return GNUNET_YES; |
817 | } | 816 | } |
818 | GNUNET_free (opc->data); | ||
819 | opc->data = NULL; | ||
820 | opc->state = OPC_STATE_FINISHED; | 817 | opc->state = OPC_STATE_FINISHED; |
821 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 818 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
822 | if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) && | 819 | if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) && |
@@ -873,12 +870,13 @@ handle_link_controllers_result (struct GNUNET_TESTBED_Controller *c, | |||
873 | GNUNET_break (0); | 870 | GNUNET_break (0); |
874 | return GNUNET_YES; | 871 | return GNUNET_YES; |
875 | } | 872 | } |
876 | data = opc->data; | 873 | GNUNET_assert (NULL != (data = opc->data)); |
877 | GNUNET_assert (NULL != data); | ||
878 | host = GNUNET_TESTBED_host_lookup_by_id_ (data->host_id); | 874 | host = GNUNET_TESTBED_host_lookup_by_id_ (data->host_id); |
879 | GNUNET_assert (NULL != host); | 875 | GNUNET_assert (NULL != host); |
880 | GNUNET_free (data); | 876 | GNUNET_free (data); |
881 | opc->data = NULL; | 877 | opc->data = NULL; |
878 | opc->state = OPC_STATE_FINISHED; | ||
879 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | ||
882 | event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; | 880 | event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; |
883 | event.op = opc->op; | 881 | event.op = opc->op; |
884 | event.op_cls = opc->op_cls; | 882 | event.op_cls = opc->op_cls; |
@@ -905,8 +903,6 @@ handle_link_controllers_result (struct GNUNET_TESTBED_Controller *c, | |||
905 | GNUNET_TESTBED_host_replace_cfg_ (host, cfg); | 903 | GNUNET_TESTBED_host_replace_cfg_ (host, cfg); |
906 | } | 904 | } |
907 | } | 905 | } |
908 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | ||
909 | opc->state = OPC_STATE_FINISHED; | ||
910 | if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED))) | 906 | if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED))) |
911 | { | 907 | { |
912 | if (NULL != c->cc) | 908 | if (NULL != c->cc) |
@@ -1218,7 +1214,7 @@ oprelease_link_controllers (void *cls) | |||
1218 | switch (opc->state) | 1214 | switch (opc->state) |
1219 | { | 1215 | { |
1220 | case OPC_STATE_INIT: | 1216 | case OPC_STATE_INIT: |
1221 | GNUNET_free (data->msg); | 1217 | GNUNET_free (data->msg); |
1222 | break; | 1218 | break; |
1223 | case OPC_STATE_STARTED: | 1219 | case OPC_STATE_STARTED: |
1224 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 1220 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
@@ -1240,11 +1236,14 @@ static void | |||
1240 | opstart_get_slave_config (void *cls) | 1236 | opstart_get_slave_config (void *cls) |
1241 | { | 1237 | { |
1242 | struct OperationContext *opc = cls; | 1238 | struct OperationContext *opc = cls; |
1243 | struct GetSlaveConfigData *data; | 1239 | struct GetSlaveConfigData *data = opc->data; |
1244 | struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg; | 1240 | struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg; |
1245 | 1241 | ||
1246 | data = opc->data; | 1242 | GNUNET_assert (NULL != data); |
1247 | msg = GNUNET_TESTBED_generate_slavegetconfig_msg_ (opc->id, data->slave_id); | 1243 | msg = GNUNET_TESTBED_generate_slavegetconfig_msg_ (opc->id, data->slave_id); |
1244 | GNUNET_free (opc->data); | ||
1245 | data = NULL; | ||
1246 | opc->data = NULL; | ||
1248 | GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc); | 1247 | GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc); |
1249 | GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); | 1248 | GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); |
1250 | opc->state = OPC_STATE_STARTED; | 1249 | opc->state = OPC_STATE_STARTED; |
@@ -1267,7 +1266,6 @@ oprelease_get_slave_config (void *cls) | |||
1267 | GNUNET_free (opc->data); | 1266 | GNUNET_free (opc->data); |
1268 | break; | 1267 | break; |
1269 | case OPC_STATE_STARTED: | 1268 | case OPC_STATE_STARTED: |
1270 | GNUNET_free (opc->data); | ||
1271 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 1269 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
1272 | break; | 1270 | break; |
1273 | case OPC_STATE_FINISHED: | 1271 | case OPC_STATE_FINISHED: |
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c index cbf2f2385..8944ec776 100644 --- a/src/testbed/testbed_api_peers.c +++ b/src/testbed/testbed_api_peers.c | |||
@@ -105,9 +105,8 @@ opstart_peer_create (void *cls) | |||
105 | size_t xc_size; | 105 | size_t xc_size; |
106 | uint16_t msize; | 106 | uint16_t msize; |
107 | 107 | ||
108 | GNUNET_assert (OP_PEER_CREATE == opc->type); | 108 | GNUNET_assert (OP_PEER_CREATE == opc->type); |
109 | data = opc->data; | 109 | GNUNET_assert (NULL != (data = opc->data)); |
110 | GNUNET_assert (NULL != data); | ||
111 | GNUNET_assert (NULL != data->peer); | 110 | GNUNET_assert (NULL != data->peer); |
112 | opc->state = OPC_STATE_STARTED; | 111 | opc->state = OPC_STATE_STARTED; |
113 | config = GNUNET_CONFIGURATION_serialize (data->cfg, &c_size); | 112 | config = GNUNET_CONFIGURATION_serialize (data->cfg, &c_size); |
@@ -166,8 +165,7 @@ opstart_peer_destroy (void *cls) | |||
166 | struct GNUNET_TESTBED_PeerDestroyMessage *msg; | 165 | struct GNUNET_TESTBED_PeerDestroyMessage *msg; |
167 | 166 | ||
168 | GNUNET_assert (OP_PEER_DESTROY == opc->type); | 167 | GNUNET_assert (OP_PEER_DESTROY == opc->type); |
169 | peer = opc->data; | 168 | GNUNET_assert (NULL != (peer = opc->data)); |
170 | GNUNET_assert (NULL != peer); | ||
171 | opc->state = OPC_STATE_STARTED; | 169 | opc->state = OPC_STATE_STARTED; |
172 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerDestroyMessage)); | 170 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerDestroyMessage)); |
173 | msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerDestroyMessage)); | 171 | msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerDestroyMessage)); |
@@ -189,8 +187,16 @@ oprelease_peer_destroy (void *cls) | |||
189 | { | 187 | { |
190 | struct OperationContext *opc = cls; | 188 | struct OperationContext *opc = cls; |
191 | 189 | ||
192 | if (OPC_STATE_FINISHED != opc->state) | 190 | switch (opc->state) |
191 | { | ||
192 | case OPC_STATE_STARTED: | ||
193 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 193 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
194 | /* no break; continue */ | ||
195 | case OPC_STATE_INIT: | ||
196 | break; | ||
197 | case OPC_STATE_FINISHED: | ||
198 | break; | ||
199 | } | ||
194 | GNUNET_free (opc); | 200 | GNUNET_free (opc); |
195 | } | 201 | } |
196 | 202 | ||
@@ -209,10 +215,8 @@ opstart_peer_start (void *cls) | |||
209 | struct GNUNET_TESTBED_Peer *peer; | 215 | struct GNUNET_TESTBED_Peer *peer; |
210 | 216 | ||
211 | GNUNET_assert (OP_PEER_START == opc->type); | 217 | GNUNET_assert (OP_PEER_START == opc->type); |
212 | GNUNET_assert (NULL != opc->data); | 218 | GNUNET_assert (NULL != (data = opc->data)); |
213 | data = opc->data; | 219 | GNUNET_assert (NULL != (peer = data->peer)); |
214 | GNUNET_assert (NULL != data->peer); | ||
215 | peer = data->peer; | ||
216 | GNUNET_assert ((PS_CREATED == peer->state) || (PS_STOPPED == peer->state)); | 220 | GNUNET_assert ((PS_CREATED == peer->state) || (PS_STOPPED == peer->state)); |
217 | opc->state = OPC_STATE_STARTED; | 221 | opc->state = OPC_STATE_STARTED; |
218 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerStartMessage)); | 222 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerStartMessage)); |
@@ -235,10 +239,16 @@ oprelease_peer_start (void *cls) | |||
235 | { | 239 | { |
236 | struct OperationContext *opc = cls; | 240 | struct OperationContext *opc = cls; |
237 | 241 | ||
238 | if (OPC_STATE_FINISHED != opc->state) | 242 | switch (opc->state) |
239 | { | 243 | { |
240 | GNUNET_free (opc->data); | 244 | case OPC_STATE_STARTED: |
241 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 245 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
246 | /* no break; continue */ | ||
247 | case OPC_STATE_INIT: | ||
248 | GNUNET_free (opc->data); | ||
249 | break; | ||
250 | case OPC_STATE_FINISHED: | ||
251 | break; | ||
242 | } | 252 | } |
243 | GNUNET_free (opc); | 253 | GNUNET_free (opc); |
244 | } | 254 | } |
@@ -257,10 +267,8 @@ opstart_peer_stop (void *cls) | |||
257 | struct PeerEventData *data; | 267 | struct PeerEventData *data; |
258 | struct GNUNET_TESTBED_Peer *peer; | 268 | struct GNUNET_TESTBED_Peer *peer; |
259 | 269 | ||
260 | GNUNET_assert (NULL != opc->data); | 270 | GNUNET_assert (NULL != (data = opc->data)); |
261 | data = opc->data; | 271 | GNUNET_assert (NULL != (peer = data->peer)); |
262 | GNUNET_assert (NULL != data->peer); | ||
263 | peer = data->peer; | ||
264 | GNUNET_assert (PS_STARTED == peer->state); | 272 | GNUNET_assert (PS_STARTED == peer->state); |
265 | opc->state = OPC_STATE_STARTED; | 273 | opc->state = OPC_STATE_STARTED; |
266 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerStopMessage)); | 274 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerStopMessage)); |
@@ -283,10 +291,16 @@ oprelease_peer_stop (void *cls) | |||
283 | { | 291 | { |
284 | struct OperationContext *opc = cls; | 292 | struct OperationContext *opc = cls; |
285 | 293 | ||
286 | if (OPC_STATE_FINISHED != opc->state) | 294 | switch (opc->state) |
287 | { | 295 | { |
288 | GNUNET_free (opc->data); | 296 | case OPC_STATE_STARTED: |
289 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 297 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
298 | /* no break; continue */ | ||
299 | case OPC_STATE_INIT: | ||
300 | GNUNET_free (opc->data); | ||
301 | break; | ||
302 | case OPC_STATE_FINISHED: | ||
303 | break; | ||
290 | } | 304 | } |
291 | GNUNET_free (opc); | 305 | GNUNET_free (opc); |
292 | } | 306 | } |
@@ -330,8 +344,7 @@ opstart_peer_getinfo (void *cls) | |||
330 | struct PeerInfoData *data; | 344 | struct PeerInfoData *data; |
331 | struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; | 345 | struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; |
332 | 346 | ||
333 | data = opc->data; | 347 | GNUNET_assert (NULL != (data = opc->data)); |
334 | GNUNET_assert (NULL != data); | ||
335 | opc->state = OPC_STATE_STARTED; | 348 | opc->state = OPC_STATE_STARTED; |
336 | msg = | 349 | msg = |
337 | GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, | 350 | GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, |
@@ -352,19 +365,21 @@ oprelease_peer_getinfo (void *cls) | |||
352 | struct OperationContext *opc = cls; | 365 | struct OperationContext *opc = cls; |
353 | struct GNUNET_TESTBED_PeerInformation *data; | 366 | struct GNUNET_TESTBED_PeerInformation *data; |
354 | 367 | ||
355 | if (OPC_STATE_FINISHED != opc->state) | 368 | switch (opc->state) |
356 | { | 369 | { |
357 | GNUNET_free_non_null (opc->data); | 370 | case OPC_STATE_STARTED: |
358 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 371 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
359 | } | 372 | /* no break; continue */ |
360 | else | 373 | case OPC_STATE_INIT: |
361 | { | 374 | GNUNET_free (opc->data); |
362 | data = opc->data; | 375 | break; |
363 | GNUNET_assert (NULL != data); | 376 | case OPC_STATE_FINISHED: |
377 | GNUNET_assert (NULL != (data = opc->data)); | ||
364 | switch (data->pit) | 378 | switch (data->pit) |
365 | { | 379 | { |
366 | case GNUNET_TESTBED_PIT_CONFIGURATION: | 380 | case GNUNET_TESTBED_PIT_CONFIGURATION: |
367 | GNUNET_CONFIGURATION_destroy (data->result.cfg); | 381 | if (NULL != data->result.cfg) |
382 | GNUNET_CONFIGURATION_destroy (data->result.cfg); | ||
368 | break; | 383 | break; |
369 | case GNUNET_TESTBED_PIT_IDENTITY: | 384 | case GNUNET_TESTBED_PIT_IDENTITY: |
370 | GNUNET_free (data->result.id); | 385 | GNUNET_free (data->result.id); |
@@ -373,6 +388,7 @@ oprelease_peer_getinfo (void *cls) | |||
373 | GNUNET_assert (0); /* We should never reach here */ | 388 | GNUNET_assert (0); /* We should never reach here */ |
374 | } | 389 | } |
375 | GNUNET_free (data); | 390 | GNUNET_free (data); |
391 | break; | ||
376 | } | 392 | } |
377 | GNUNET_free (opc); | 393 | GNUNET_free (opc); |
378 | } | 394 | } |