diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-14 12:36:28 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-14 12:36:28 +0000 |
commit | 6e63250cca222a1cd818b05fc3d027dfb37554ab (patch) | |
tree | 95f2c242cad3e762eb64661eeec035baa25dc6b4 /src/testbed/gnunet-testbed-profiler.c | |
parent | 75357bec5d503045dcf5d5cfd5805300e0605d9d (diff) | |
download | gnunet-6e63250cca222a1cd818b05fc3d027dfb37554ab.tar.gz gnunet-6e63250cca222a1cd818b05fc3d027dfb37554ab.zip |
peer start
Diffstat (limited to 'src/testbed/gnunet-testbed-profiler.c')
-rw-r--r-- | src/testbed/gnunet-testbed-profiler.c | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c index 4144c3da5..21280b75c 100644 --- a/src/testbed/gnunet-testbed-profiler.c +++ b/src/testbed/gnunet-testbed-profiler.c | |||
@@ -241,6 +241,42 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
241 | 241 | ||
242 | /** | 242 | /** |
243 | * Functions of this signature are called when a peer has been successfully | 243 | * Functions of this signature are called when a peer has been successfully |
244 | * started or stopped. | ||
245 | * | ||
246 | * @param cls the closure from GNUNET_TESTBED_peer_start/stop() | ||
247 | * @param emsg NULL on success; otherwise an error description | ||
248 | */ | ||
249 | static void | ||
250 | peer_churn_cb (void *cls, const char *emsg) | ||
251 | { | ||
252 | struct DLLOperation *dll_op = cls; | ||
253 | struct GNUNET_TESTBED_Operation *op; | ||
254 | static unsigned int started_peers; | ||
255 | |||
256 | op = dll_op->op; | ||
257 | GNUNET_CONTAINER_DLL_remove (dll_op_head, dll_op_tail, dll_op); | ||
258 | GNUNET_free (dll_op); | ||
259 | if (NULL != emsg) | ||
260 | { | ||
261 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
262 | _("An operation has failed while starting peers\n")); | ||
263 | GNUNET_TESTBED_operation_done (op); | ||
264 | GNUNET_SCHEDULER_cancel (abort_task); | ||
265 | abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); | ||
266 | return; | ||
267 | } | ||
268 | GNUNET_TESTBED_operation_done (op); | ||
269 | if (++started_peers == num_peers) | ||
270 | { | ||
271 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); | ||
272 | printf ("All peers started successfully in %.2f seconds\n", | ||
273 | ((double) prof_time.rel_value) / 1000.00); | ||
274 | } | ||
275 | } | ||
276 | |||
277 | |||
278 | /** | ||
279 | * Functions of this signature are called when a peer has been successfully | ||
244 | * created | 280 | * created |
245 | * | 281 | * |
246 | * @param cls the closure from GNUNET_TESTBED_peer_create() | 282 | * @param cls the closure from GNUNET_TESTBED_peer_create() |
@@ -283,7 +319,8 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | |||
283 | for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) | 319 | for (peer_cnt = 0; peer_cnt < num_peers; peer_cnt++) |
284 | { | 320 | { |
285 | dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); | 321 | dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); |
286 | dll_op->op = GNUNET_TESTBED_peer_start (NULL, peers[peer_cnt], NULL, NULL); | 322 | dll_op->op = GNUNET_TESTBED_peer_start (NULL, peers[peer_cnt], |
323 | &peer_churn_cb, dll_op); | ||
287 | GNUNET_CONTAINER_DLL_insert_tail (dll_op_head, dll_op_tail, dll_op); | 324 | GNUNET_CONTAINER_DLL_insert_tail (dll_op_head, dll_op_tail, dll_op); |
288 | } | 325 | } |
289 | } | 326 | } |
@@ -359,10 +396,8 @@ controller_event_cb (void *cls, | |||
359 | { | 396 | { |
360 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: | 397 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: |
361 | /* Control reaches here when peer start fails */ | 398 | /* Control reaches here when peer start fails */ |
362 | GNUNET_break (0); | ||
363 | break; | ||
364 | case GNUNET_TESTBED_ET_PEER_START: | 399 | case GNUNET_TESTBED_ET_PEER_START: |
365 | GNUNET_break (0); | 400 | /* we handle peer starts in peer_churn_cb */ |
366 | break; | 401 | break; |
367 | default: | 402 | default: |
368 | GNUNET_assert (0); | 403 | GNUNET_assert (0); |