diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-05-05 18:48:18 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-05-05 18:48:18 +0000 |
commit | daa1608a8c4cfe8b8510656cd233c4642db20d04 (patch) | |
tree | 728d107f96ace50d17561c450822c1a2d129cb63 /src/testbed/gnunet-service-testbed_links.c | |
parent | 843f898e3d1391aba7003e6e7c9ec0d7b3530fac (diff) | |
download | gnunet-daa1608a8c4cfe8b8510656cd233c4642db20d04.tar.gz gnunet-daa1608a8c4cfe8b8510656cd233c4642db20d04.zip |
- simplify on-demand linking in overlay connects
Diffstat (limited to 'src/testbed/gnunet-service-testbed_links.c')
-rw-r--r-- | src/testbed/gnunet-service-testbed_links.c | 48 |
1 files changed, 13 insertions, 35 deletions
diff --git a/src/testbed/gnunet-service-testbed_links.c b/src/testbed/gnunet-service-testbed_links.c index 6209bf248..1da071660 100644 --- a/src/testbed/gnunet-service-testbed_links.c +++ b/src/testbed/gnunet-service-testbed_links.c | |||
@@ -326,10 +326,6 @@ reghost_free_iterator (void *cls, const struct GNUNET_HashCode *key, | |||
326 | GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, rhc->focc_dll_tail, focc); | 326 | GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, rhc->focc_dll_tail, focc); |
327 | GST_cleanup_focc (focc); | 327 | GST_cleanup_focc (focc); |
328 | } | 328 | } |
329 | if (NULL != rhc->sub_op) | ||
330 | GNUNET_TESTBED_operation_done (rhc->sub_op); | ||
331 | if (NULL != rhc->client) | ||
332 | GNUNET_SERVER_client_drop (rhc->client); | ||
333 | GNUNET_free (value); | 329 | GNUNET_free (value); |
334 | return GNUNET_YES; | 330 | return GNUNET_YES; |
335 | } | 331 | } |
@@ -618,39 +614,11 @@ static void | |||
618 | slave_event_callback (void *cls, | 614 | slave_event_callback (void *cls, |
619 | const struct GNUNET_TESTBED_EventInformation *event) | 615 | const struct GNUNET_TESTBED_EventInformation *event) |
620 | { | 616 | { |
621 | struct RegisteredHostContext *rhc; | ||
622 | struct LCFContext *lcf; | 617 | struct LCFContext *lcf; |
623 | struct GNUNET_TESTBED_Operation *old_op; | ||
624 | 618 | ||
625 | /* We currently only get here when working on RegisteredHostContexts and | 619 | /* We currently only get here when working on RegisteredHostContexts and |
626 | LCFContexts */ | 620 | LCFContexts */ |
627 | GNUNET_assert (GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type); | 621 | GNUNET_assert (GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type); |
628 | rhc = event->op_cls; | ||
629 | if (CLOSURE_TYPE_RHC == rhc->type) | ||
630 | { | ||
631 | GNUNET_assert (rhc->sub_op == event->op); | ||
632 | switch (rhc->state) | ||
633 | { | ||
634 | case RHC_GET_CFG: | ||
635 | old_op = rhc->sub_op; | ||
636 | rhc->state = RHC_LINK; | ||
637 | rhc->sub_op = | ||
638 | GNUNET_TESTBED_controller_link (rhc, rhc->gateway->controller, | ||
639 | rhc->reg_host, rhc->host, GNUNET_NO); | ||
640 | GNUNET_TESTBED_operation_done (old_op); | ||
641 | break; | ||
642 | case RHC_LINK: | ||
643 | LOG_DEBUG ("OL: Linking controllers successfull\n"); | ||
644 | GNUNET_TESTBED_operation_done (rhc->sub_op); | ||
645 | rhc->sub_op = NULL; | ||
646 | rhc->state = RHC_OL_CONNECT; | ||
647 | GST_process_next_focc (rhc); | ||
648 | break; | ||
649 | default: | ||
650 | GNUNET_assert (0); | ||
651 | } | ||
652 | return; | ||
653 | } | ||
654 | lcf = event->op_cls; | 622 | lcf = event->op_cls; |
655 | if (CLOSURE_TYPE_LCF == lcf->type) | 623 | if (CLOSURE_TYPE_LCF == lcf->type) |
656 | { | 624 | { |
@@ -955,6 +923,18 @@ neighbour_connect_cb (void *cls, struct GNUNET_TESTBED_Controller *c) | |||
955 | cleanup_ncc (ncc); | 923 | cleanup_ncc (ncc); |
956 | } | 924 | } |
957 | 925 | ||
926 | struct Neighbour * | ||
927 | GST_create_neighbour (struct GNUNET_TESTBED_Host *host) | ||
928 | { | ||
929 | struct Neighbour *n; | ||
930 | |||
931 | n = GNUNET_malloc (sizeof (struct Neighbour)); | ||
932 | n->host_id = GNUNET_TESTBED_host_get_id_ (host); | ||
933 | neighbour_list_add (n); /* just add; connect on-demand */ | ||
934 | return n; | ||
935 | } | ||
936 | |||
937 | |||
958 | /** | 938 | /** |
959 | * Message handler for GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS message | 939 | * Message handler for GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS message |
960 | * | 940 | * |
@@ -1033,9 +1013,7 @@ GST_handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, | |||
1033 | } | 1013 | } |
1034 | LOG_DEBUG ("Received request to establish a link to host %u\n", | 1014 | LOG_DEBUG ("Received request to establish a link to host %u\n", |
1035 | delegated_host_id); | 1015 | delegated_host_id); |
1036 | n = GNUNET_malloc (sizeof (struct Neighbour)); | 1016 | n = GST_create_neighbour (GST_host_list[delegated_host_id]); |
1037 | n->host_id = delegated_host_id; | ||
1038 | neighbour_list_add (n); /* just add; connect on-demand */ | ||
1039 | ncc = GNUNET_malloc (sizeof (struct NeighbourConnectCtxt)); | 1017 | ncc = GNUNET_malloc (sizeof (struct NeighbourConnectCtxt)); |
1040 | ncc->n = n; | 1018 | ncc->n = n; |
1041 | ncc->op_id = op_id; | 1019 | ncc->op_id = op_id; |