aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-03-19 14:06:43 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-03-19 14:06:43 +0000
commite938a1e58a100e439d86fe1b539c3f1ea762b0f6 (patch)
treee06262ddba6e01e79093eeb54c81a03a6109916e /src/testbed
parenta15a0d82708f6d021dbd974aba3d712fe722d20f (diff)
downloadgnunet-e938a1e58a100e439d86fe1b539c3f1ea762b0f6.tar.gz
gnunet-e938a1e58a100e439d86fe1b539c3f1ea762b0f6.zip
- mark statistics service connect operations done when statistics iteration
completes
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/test_testbed_api_statistics.conf1
-rw-r--r--src/testbed/testbed_api_statistics.c37
2 files changed, 37 insertions, 1 deletions
diff --git a/src/testbed/test_testbed_api_statistics.conf b/src/testbed/test_testbed_api_statistics.conf
index 36de44147..c0836727a 100644
--- a/src/testbed/test_testbed_api_statistics.conf
+++ b/src/testbed/test_testbed_api_statistics.conf
@@ -5,6 +5,7 @@ ACCEPT_FROM = 127.0.0.1;
5HOSTNAME = localhost 5HOSTNAME = localhost
6NEIGHBOUR_LIMIT = 100 6NEIGHBOUR_LIMIT = 100
7OVERLAY_TOPOLOGY = 2D_TORUS 7OVERLAY_TOPOLOGY = 2D_TORUS
8MAX_PARALLEL_SERVICE_CONNECTIONS = 2
8#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args 9#PREFIX = xterm -geometry 100x85 -T peer1 -e libtool --mode=execute gdb --args
9 10
10[fs] 11[fs]
diff --git a/src/testbed/testbed_api_statistics.c b/src/testbed/testbed_api_statistics.c
index d6af1bce2..dac468232 100644
--- a/src/testbed/testbed_api_statistics.c
+++ b/src/testbed/testbed_api_statistics.c
@@ -116,6 +116,11 @@ struct PeerGetStatsContext
116 struct GNUNET_STATISTICS_GetHandle *get_handle; 116 struct GNUNET_STATISTICS_GetHandle *get_handle;
117 117
118 /** 118 /**
119 * Task to mark the statistics service connect operation as done
120 */
121 GNUNET_SCHEDULER_TaskIdentifier op_done_task_id;
122
123 /**
119 * The index of this peer in the peers array of GetStatsContext 124 * The index of this peer in the peers array of GetStatsContext
120 */ 125 */
121 unsigned int peer_index; 126 unsigned int peer_index;
@@ -150,6 +155,29 @@ call_completion_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
150 155
151 156
152/** 157/**
158 * Task to mark statistics service connect operation as done. We call it here
159 * as we cannot destroy the statistics handle in iteration_completion_cb()
160 *
161 * @param cls the PeerGetStatsContext
162 * @param tc the scheduler task context
163 */
164static void
165op_done_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
166{
167 struct PeerGetStatsContext *peer_sc = cls;
168 struct GetStatsContext *sc;
169 struct GNUNET_TESTBED_Operation **op;
170
171 sc = peer_sc->sc;
172 peer_sc->op_done_task_id = GNUNET_SCHEDULER_NO_TASK;
173 op = &sc->ops[peer_sc->peer_index];
174 GNUNET_assert (NULL != *op);
175 GNUNET_TESTBED_operation_done (*op);
176 *op = NULL;
177}
178
179
180/**
153 * Continuation called by the "get_all" and "get" functions. 181 * Continuation called by the "get_all" and "get" functions.
154 * 182 *
155 * @param cls the PeerGetStatsContext 183 * @param cls the PeerGetStatsContext
@@ -164,7 +192,8 @@ iteration_completion_cb (void *cls, int success)
164 192
165 if (NULL == peer_sc->get_handle) 193 if (NULL == peer_sc->get_handle)
166 { 194 {
167 /* We are being called after we cancelled the GetHandle */ 195 /* We are being called synchronously in call to GNUNET_STATISTICS_destroy()
196 in statistics_da() after we cancelled the GetHandle */
168 GNUNET_assert (GNUNET_SYSERR == success); 197 GNUNET_assert (GNUNET_SYSERR == success);
169 return; 198 return;
170 } 199 }
@@ -172,6 +201,7 @@ iteration_completion_cb (void *cls, int success)
172 sc = peer_sc->sc; 201 sc = peer_sc->sc;
173 peer_sc->get_handle = NULL; 202 peer_sc->get_handle = NULL;
174 sc->num_completed++; 203 sc->num_completed++;
204 peer_sc->op_done_task_id = GNUNET_SCHEDULER_add_now (&op_done_task, peer_sc);
175 if (sc->num_completed == sc->num_peers) 205 if (sc->num_completed == sc->num_peers)
176 { 206 {
177 LOG_DEBUG ("Scheduling to call iteration completion callback\n"); 207 LOG_DEBUG ("Scheduling to call iteration completion callback\n");
@@ -279,6 +309,8 @@ statistics_da (void *cls, void *op_result)
279 } 309 }
280 GNUNET_STATISTICS_destroy ((struct GNUNET_STATISTICS_Handle *) op_result, 310 GNUNET_STATISTICS_destroy ((struct GNUNET_STATISTICS_Handle *) op_result,
281 GNUNET_NO); 311 GNUNET_NO);
312 if (GNUNET_SCHEDULER_NO_TASK != peer_sc->op_done_task_id)
313 GNUNET_SCHEDULER_cancel (peer_sc->op_done_task_id);
282 GNUNET_free (peer_sc); 314 GNUNET_free (peer_sc);
283} 315}
284 316
@@ -333,7 +365,10 @@ oprelease_get_stats (void *cls)
333 for (peer = 0; peer < sc->num_peers; peer++) 365 for (peer = 0; peer < sc->num_peers; peer++)
334 { 366 {
335 if (NULL != sc->ops[peer]) 367 if (NULL != sc->ops[peer])
368 {
336 GNUNET_TESTBED_operation_done (sc->ops[peer]); 369 GNUNET_TESTBED_operation_done (sc->ops[peer]);
370 sc->ops[peer] = NULL;
371 }
337 } 372 }
338 GNUNET_free (sc->ops); 373 GNUNET_free (sc->ops);
339 } 374 }