aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_cmd_netjail_start_testbed.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/testbed_api_cmd_netjail_start_testbed.c')
-rw-r--r--src/testbed/testbed_api_cmd_netjail_start_testbed.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/src/testbed/testbed_api_cmd_netjail_start_testbed.c b/src/testbed/testbed_api_cmd_netjail_start_testbed.c
index 585825cbc..bc4674b74 100644
--- a/src/testbed/testbed_api_cmd_netjail_start_testbed.c
+++ b/src/testbed/testbed_api_cmd_netjail_start_testbed.c
@@ -89,6 +89,8 @@ struct NetJailState
89 89
90 unsigned int number_of_peers_started; 90 unsigned int number_of_peers_started;
91 91
92 unsigned int number_of_local_test_finished;
93
92 /** 94 /**
93 * The host where the controller is running 95 * The host where the controller is running
94 */ 96 */
@@ -256,6 +258,14 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
256 message->type)) 258 message->type))
257 { 259 {
258 ns->number_of_peers_started++; 260 ns->number_of_peers_started++;
261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
262 "number_of_peers_started: %d\n",
263 ns->number_of_peers_started);
264 }
265 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs (
266 message->type))
267 {
268 ns->number_of_local_test_finished++;
259 } 269 }
260 else 270 else
261 { 271 {
@@ -375,7 +385,8 @@ start_testbed (struct NetJailState *ns, struct
375 tbc)); 385 tbc));
376 386
377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 387 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
378 "Message send!\n"); 388 "Message %d send!\n",
389 tbc->count);
379 390
380 if (NULL == ns->shandle[tbc->count - 1]) 391 if (NULL == ns->shandle[tbc->count - 1])
381 { 392 {
@@ -426,17 +437,22 @@ netjail_start_finish (void *cls,
426 unsigned int ret = GNUNET_NO; 437 unsigned int ret = GNUNET_NO;
427 struct NetJailState *ns = cls; 438 struct NetJailState *ns = cls;
428 unsigned int total_number = atoi (ns->local_m) * atoi (ns->global_n); 439 unsigned int total_number = atoi (ns->local_m) * atoi (ns->global_n);
429 struct GNUNET_CMDS_PEER_STARTED *reply; 440 struct GNUNET_CMDS_ALL_PEERS_STARTED *reply;
430 size_t msg_length; 441 size_t msg_length;
431 struct GNUNET_HELPER_Handle *helper; 442 struct GNUNET_HELPER_Handle *helper;
432 struct TestbedCount *tbc; 443 struct TestbedCount *tbc;
433 444
445 if (ns->number_of_local_test_finished == total_number)
446 {
447 ret = GNUNET_YES;
448 cont (cont_cls);
449 }
450
434 if (ns->number_of_testbeds_started == total_number) 451 if (ns->number_of_testbeds_started == total_number)
435 { 452 {
436 /* ret = GNUNET_YES;
437 cont (cont_cls);*/
438 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 453 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
439 "All helpers started!\n"); 454 "All helpers started!\n");
455 ns->number_of_testbeds_started = 0;
440 } 456 }
441 457
442 if (ns->number_of_peers_started == total_number) 458 if (ns->number_of_peers_started == total_number)
@@ -449,9 +465,9 @@ netjail_start_finish (void *cls,
449 { 465 {
450 tbc = GNUNET_new (struct TestbedCount); 466 tbc = GNUNET_new (struct TestbedCount);
451 tbc->ns = ns; 467 tbc->ns = ns;
452 tbc->count = (j - 1) * atoi (ns->local_m) + i + atoi (ns->global_n) 468 // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone.
453 * atoi (ns->local_m); 469 tbc->count = (j - 1) * atoi (ns->local_m) + i + total_number;
454 helper = ns->helper[tbc->count - 1]; 470 helper = ns->helper[tbc->count - 1 - total_number];
455 msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED); 471 msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED);
456 reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED); 472 reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED);
457 reply->header.type = htons ( 473 reply->header.type = htons (
@@ -460,14 +476,21 @@ netjail_start_finish (void *cls,
460 476
461 GNUNET_array_append (ns->msg, ns->n_msg, &reply->header); 477 GNUNET_array_append (ns->msg, ns->n_msg, &reply->header);
462 478
463 GNUNET_array_append (ns->shandle, ns->n_shandle, GNUNET_HELPER_send ( 479 struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send (
464 helper, 480 helper,
465 &reply->header, 481 &reply->header,
466 GNUNET_NO, 482 GNUNET_NO,
467 &clear_msg, 483 &clear_msg,
468 tbc)); 484 tbc);
485
486 GNUNET_array_append (ns->shandle, ns->n_shandle, sh);
487
488 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
489 "All peers started message %d send!\n",
490 tbc->count);
469 } 491 }
470 } 492 }
493 ns->number_of_peers_started = 0;
471 } 494 }
472 return ret; 495 return ret;
473} 496}