aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-02-04 22:22:15 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-02-04 22:22:15 +0000
commit17c860b4bd0d0d0afa5002c6c08c6a21763c23e8 (patch)
tree15c34754990ff6dd82776c54327ebac9c8edb37f
parent9815c9428b6cffa128244d2186197adf7208b7ee (diff)
downloadgnunet-17c860b4bd0d0d0afa5002c6c08c6a21763c23e8.tar.gz
gnunet-17c860b4bd0d0d0afa5002c6c08c6a21763c23e8.zip
- check whether an operation gets cleaned before calling secondary callback
-rw-r--r--src/testbed/testbed_api.c14
-rw-r--r--src/testbed/testbed_api_testbed.c8
2 files changed, 21 insertions, 1 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index bf9f18a38..054aa3bfa 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -312,6 +312,17 @@ struct SDHandle
312 312
313 313
314/** 314/**
315 * This variable is set to the operation that has been last marked as done. It
316 * is used to verify whether the state associated with an operation is valid
317 * after the first notify callback is called. Such checks are necessary for
318 * certain operations where we have 2 notify callbacks. Examples are
319 * OP_PEER_CREATE, OP_PEER_START/STOP, OP_OVERLAY_CONNECT.
320 *
321 * This variable should ONLY be used to compare; it is a dangling pointer!!
322 */
323static const struct GNUNET_TESTBED_Operation *last_finished_operation;
324
325/**
315 * Initialize standard deviation calculation handle 326 * Initialize standard deviation calculation handle
316 * 327 *
317 * @param max_cnt the maximum number of readings to keep 328 * @param max_cnt the maximum number of readings to keep
@@ -909,6 +920,8 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c,
909 event.details.operation_finished.emsg = emsg; 920 event.details.operation_finished.emsg = emsg;
910 event.details.operation_finished.generic = NULL; 921 event.details.operation_finished.generic = NULL;
911 c->cc (c->cc_cls, &event); 922 c->cc (c->cc_cls, &event);
923 if (event.details.operation_finished.operation == last_finished_operation)
924 return GNUNET_YES;
912 } 925 }
913 switch (opc->type) 926 switch (opc->type)
914 { 927 {
@@ -2468,6 +2481,7 @@ GNUNET_TESTBED_operation_cancel (struct GNUNET_TESTBED_Operation *operation)
2468void 2481void
2469GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation) 2482GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation)
2470{ 2483{
2484 last_finished_operation = operation;
2471 GNUNET_TESTBED_operation_release_ (operation); 2485 GNUNET_TESTBED_operation_release_ (operation);
2472} 2486}
2473 2487
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index 6581fffe6..47e0edc89 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -92,6 +92,11 @@ enum State
92 RC_LINKED, 92 RC_LINKED,
93 93
94 /** 94 /**
95 * Peers are created
96 */
97 RC_PEERS_CREATED,
98
99 /**
95 * The testbed run is ready and the master callback can be called now. At this 100 * The testbed run is ready and the master callback can be called now. At this
96 * time the peers are all started and if a topology is provided in the 101 * time the peers are all started and if a topology is provided in the
97 * configuration the topology would have been attempted 102 * configuration the topology would have been attempted
@@ -356,6 +361,7 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
356 if (rc->peer_count < rc->num_peers) 361 if (rc->peer_count < rc->num_peers)
357 return; 362 return;
358 DEBUG ("%u peers created in %s\n", rc->num_peers, prof_time (rc)); 363 DEBUG ("%u peers created in %s\n", rc->num_peers, prof_time (rc));
364 rc->state = RC_PEERS_CREATED;
359 GNUNET_SCHEDULER_add_now (&start_peers_task, rc); 365 GNUNET_SCHEDULER_add_now (&start_peers_task, rc);
360} 366}
361 367
@@ -675,7 +681,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
675 return; 681 return;
676 switch (rc->state) 682 switch (rc->state)
677 { 683 {
678 case RC_LINKED: 684 case RC_PEERS_CREATED:
679 case RC_READY: 685 case RC_READY:
680 rc->state = RC_PEERS_STOPPED; 686 rc->state = RC_PEERS_STOPPED;
681 DEBUG ("Peers stopped in %s\n", prof_time (rc)); 687 DEBUG ("Peers stopped in %s\n", prof_time (rc));