aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/testbed_api.c')
-rw-r--r--src/testbed/testbed_api.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 5af8d71c6..6cdcabdd6 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -444,12 +444,18 @@ struct GNUNET_TESTBED_ControllerProc
444 * The closure for the above callback 444 * The closure for the above callback
445 */ 445 */
446 void *cls; 446 void *cls;
447
447 /** 448 /**
448 * The send handle for the helper 449 * The send handle for the helper
449 */ 450 */
450 struct GNUNET_HELPER_SendHandle *shandle; 451 struct GNUNET_HELPER_SendHandle *shandle;
451 452
452 /** 453 /**
454 * The message corresponding to send handle
455 */
456 struct GNUNET_MessageHeader *msg;
457
458 /**
453 * The port number for ssh; used for helpers starting ssh 459 * The port number for ssh; used for helpers starting ssh
454 */ 460 */
455 char *port; 461 char *port;
@@ -484,6 +490,7 @@ static int helper_mst (void *cls, void *client,
484{ 490{
485 struct GNUNET_TESTBED_ControllerProc *cp = cls; 491 struct GNUNET_TESTBED_ControllerProc *cp = cls;
486 const struct GNUNET_TESTBED_HelperReply *msg; 492 const struct GNUNET_TESTBED_HelperReply *msg;
493 const char *hostname;
487 char *config; 494 char *config;
488 uLongf config_size; 495 uLongf config_size;
489 uLongf xconfig_size; 496 uLongf xconfig_size;
@@ -503,10 +510,13 @@ static int helper_mst (void *cls, void *client,
503 cp->cfg = GNUNET_CONFIGURATION_create (); 510 cp->cfg = GNUNET_CONFIGURATION_create ();
504 GNUNET_assert (GNUNET_CONFIGURATION_deserialize (cp->cfg, config, 511 GNUNET_assert (GNUNET_CONFIGURATION_deserialize (cp->cfg, config,
505 config_size, GNUNET_NO)); 512 config_size, GNUNET_NO));
513 GNUNET_free (config);
514 if ((NULL == cp->host) ||
515 (NULL == (hostname = GNUNET_TESTBED_host_get_hostname_ (cp->host))))
516 hostname = "localhost";
506 /* Change the hostname so that we can connect to it */ 517 /* Change the hostname so that we can connect to it */
507 GNUNET_CONFIGURATION_set_value_string (cp->cfg, "testbed", "hostname", 518 GNUNET_CONFIGURATION_set_value_string (cp->cfg, "testbed", "hostname",
508 (NULL == cp->host) ? "localhost" : 519 hostname);
509 GNUNET_TESTBED_host_get_hostname_ (cp->host));
510 cp->cb (cp->cls, cp->cfg, GNUNET_OK); 520 cp->cb (cp->cls, cp->cfg, GNUNET_OK);
511 return GNUNET_OK; 521 return GNUNET_OK;
512} 522}
@@ -523,7 +533,11 @@ static int helper_mst (void *cls, void *client,
523static void 533static void
524clear_msg (void *cls, int result) 534clear_msg (void *cls, int result)
525{ 535{
526 GNUNET_free (cls); 536 struct GNUNET_TESTBED_ControllerProc *cp = cls;
537
538 GNUNET_assert (NULL != cp->shandle);
539 cp->shandle = NULL;
540 GNUNET_free (cp->msg);
527} 541}
528 542
529 543
@@ -561,10 +575,11 @@ helper_exp_cb (void *cls)
561 * configuration (port numbers, unix domain sockets and service home 575 * configuration (port numbers, unix domain sockets and service home
562 * values are changed as per TESTING library on the remote host) 576 * values are changed as per TESTING library on the remote host)
563 * @param cb function called when the controller is successfully started or 577 * @param cb function called when the controller is successfully started or
564 * dies unexpectedly; GNUNET_TESTBED_controller_stop shouldn't be 578 * dies unexpectedly; GNUNET_TESTBED_controller_stop shouldn't be
565 * called if cb is called with GNUNET_SYSERR as status. Will never be 579 * called if cb is called with GNUNET_SYSERR as status. Will never be
566 * called in the same task as 'GNUNET_TESTBED_controller_start' 580 * called in the same task as 'GNUNET_TESTBED_controller_start'
567 * (synchronous errors will be signalled by returning NULL) 581 * (synchronous errors will be signalled by returning NULL). This
582 * parameter cannot be NULL.
568 * @param cls closure for above callbacks 583 * @param cls closure for above callbacks
569 * @return the controller process handle, NULL on errors 584 * @return the controller process handle, NULL on errors
570 */ 585 */
@@ -625,8 +640,9 @@ GNUNET_TESTBED_controller_start (const char *controller_ip,
625 cp->cb = cb; 640 cp->cb = cb;
626 cp->cls = cls; 641 cp->cls = cls;
627 msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, cfg); 642 msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, cfg);
643 cp->msg = &msg->header;
628 cp->shandle = GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, 644 cp->shandle = GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO,
629 &clear_msg, msg); 645 &clear_msg, cp);
630 if (NULL == cp->shandle) 646 if (NULL == cp->shandle)
631 { 647 {
632 GNUNET_free (msg); 648 GNUNET_free (msg);
@@ -650,6 +666,8 @@ GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_ControllerProc *cp)
650 if (NULL != cp->shandle) 666 if (NULL != cp->shandle)
651 GNUNET_HELPER_send_cancel (cp->shandle); 667 GNUNET_HELPER_send_cancel (cp->shandle);
652 GNUNET_HELPER_stop (cp->helper); 668 GNUNET_HELPER_stop (cp->helper);
669 if (NULL != cp->cfg)
670 GNUNET_CONFIGURATION_destroy (cp->cfg);
653 GNUNET_free_non_null (cp->port); 671 GNUNET_free_non_null (cp->port);
654 GNUNET_free_non_null (cp->dst); 672 GNUNET_free_non_null (cp->dst);
655 GNUNET_free (cp); 673 GNUNET_free (cp);