diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-02-22 14:53:28 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-02-22 14:53:28 +0000 |
commit | f6a740636d7a43be40a13b2c5c83ec4c3e6f81a5 (patch) | |
tree | 8ea61a8c0fd4acce519ef624995963add3d3524e /src | |
parent | 21f7abb96a59ece024cf63e72b3fb91eed6409e1 (diff) | |
download | gnunet-f6a740636d7a43be40a13b2c5c83ec4c3e6f81a5.tar.gz gnunet-f6a740636d7a43be40a13b2c5c83ec4c3e6f81a5.zip |
Use a sub operation while forwarding controller link operations. This helps to
propagate the change in a host's configuration along the controller tree's
branch back to root.
Diffstat (limited to 'src')
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 207 | ||||
-rw-r--r-- | src/testbed/gnunet-service-testbed.h | 56 | ||||
-rw-r--r-- | src/testbed/gnunet-service-testbed_oc.c | 12 | ||||
-rw-r--r-- | src/testbed/testbed_api.c | 31 |
4 files changed, 158 insertions, 148 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index ff7580f26..2e1af39b9 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -727,27 +727,6 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | |||
727 | 727 | ||
728 | 728 | ||
729 | /** | 729 | /** |
730 | * Callback to be called when forwarded link controllers operation is | ||
731 | * successfull. We have to relay the reply msg back to the client | ||
732 | * | ||
733 | * @param cls the LCFContext | ||
734 | * @param msg the message to relay | ||
735 | */ | ||
736 | static void | ||
737 | lcf_forwarded_operation_reply_relay (void *cls, | ||
738 | const struct GNUNET_MessageHeader *msg) | ||
739 | { | ||
740 | struct LCFContext *lcf = cls; | ||
741 | |||
742 | GNUNET_assert (NULL != lcf->fopc); | ||
743 | GST_forwarded_operation_reply_relay (lcf->fopc, msg); | ||
744 | lcf->fopc = NULL; | ||
745 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | ||
746 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | ||
747 | } | ||
748 | |||
749 | |||
750 | /** | ||
751 | * Task to free resources when forwarded link controllers has been timedout | 730 | * Task to free resources when forwarded link controllers has been timedout |
752 | * | 731 | * |
753 | * @param cls the LCFContext | 732 | * @param cls the LCFContext |
@@ -758,19 +737,12 @@ lcf_forwarded_operation_timeout (void *cls, | |||
758 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 737 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
759 | { | 738 | { |
760 | struct LCFContext *lcf = cls; | 739 | struct LCFContext *lcf = cls; |
761 | struct ForwardedOperationContext *fopc = lcf->fopc; | ||
762 | 740 | ||
763 | GNUNET_assert (NULL != lcf->fopc); | 741 | lcf->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
764 | lcf->fopc->timeout_task = GNUNET_SCHEDULER_NO_TASK; | ||
765 | // GST_forwarded_operation_timeout (lcf->fopc, tc); | 742 | // GST_forwarded_operation_timeout (lcf->fopc, tc); |
766 | GNUNET_TESTBED_forward_operation_msg_cancel_ (fopc->opc); | ||
767 | LOG (GNUNET_ERROR_TYPE_WARNING, | 743 | LOG (GNUNET_ERROR_TYPE_WARNING, |
768 | "A forwarded operation as part of controller linking has timed out\n"); | 744 | "A forwarded controller link operation has timed out\n"); |
769 | send_controller_link_response (fopc->client, fopc->operation_id, NULL, "Timeout"); | 745 | send_controller_link_response (lcf->client, lcf->operation_id, NULL, "Timeout"); |
770 | GNUNET_SERVER_client_drop (fopc->client); | ||
771 | GNUNET_CONTAINER_DLL_remove (fopcq_head, fopcq_tail, fopc); | ||
772 | GNUNET_free (fopc); | ||
773 | lcf->fopc = NULL; | ||
774 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | 746 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); |
775 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | 747 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); |
776 | } | 748 | } |
@@ -821,26 +793,24 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
821 | } | 793 | } |
822 | break; | 794 | break; |
823 | case SLAVE_HOST_REGISTERED: | 795 | case SLAVE_HOST_REGISTERED: |
824 | lcf->fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); | 796 | lcf->op = GNUNET_TESTBED_controller_link (lcf, |
825 | lcf->fopc->client = lcf->client; | 797 | lcf->gateway->controller, |
826 | lcf->fopc->operation_id = lcf->operation_id; | 798 | GST_host_list[lcf->delegated_host_id], |
827 | lcf->fopc->type = OP_LINK_CONTROLLERS; | 799 | GST_host_list[lcf->slave_host_id], |
828 | lcf->fopc->opc = | 800 | NULL, |
829 | GNUNET_TESTBED_forward_operation_msg_ (lcf->gateway->controller, | 801 | lcf->is_subordinate); |
830 | lcf->operation_id, | 802 | lcf->timeout_task = |
831 | &lcf->msg->header, | ||
832 | &lcf_forwarded_operation_reply_relay, | ||
833 | lcf); | ||
834 | lcf->fopc->timeout_task = | ||
835 | GNUNET_SCHEDULER_add_delayed (GST_timeout, &lcf_forwarded_operation_timeout, | 803 | GNUNET_SCHEDULER_add_delayed (GST_timeout, &lcf_forwarded_operation_timeout, |
836 | lcf); | 804 | lcf); |
837 | GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, lcf->fopc); | ||
838 | lcf->state = FINISHED; | 805 | lcf->state = FINISHED; |
839 | break; | 806 | break; |
840 | case FINISHED: | 807 | case FINISHED: |
841 | lcfq = lcfq_head; | 808 | lcfq = lcfq_head; |
842 | GNUNET_assert (lcfq->lcf == lcf); | 809 | GNUNET_assert (lcfq->lcf == lcf); |
843 | GNUNET_free (lcf->msg); | 810 | GNUNET_assert (NULL != lcf->cfg); |
811 | GNUNET_CONFIGURATION_destroy (lcf->cfg); | ||
812 | GNUNET_SERVER_client_drop (lcf->client); | ||
813 | GNUNET_TESTBED_operation_done (lcf->op); | ||
844 | GNUNET_free (lcf); | 814 | GNUNET_free (lcf); |
845 | GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq); | 815 | GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq); |
846 | GNUNET_free (lcfq); | 816 | GNUNET_free (lcfq); |
@@ -862,35 +832,62 @@ slave_event_callback (void *cls, | |||
862 | const struct GNUNET_TESTBED_EventInformation *event) | 832 | const struct GNUNET_TESTBED_EventInformation *event) |
863 | { | 833 | { |
864 | struct RegisteredHostContext *rhc; | 834 | struct RegisteredHostContext *rhc; |
835 | struct LCFContext *lcf; | ||
865 | struct GNUNET_CONFIGURATION_Handle *cfg; | 836 | struct GNUNET_CONFIGURATION_Handle *cfg; |
866 | struct GNUNET_TESTBED_Operation *old_op; | 837 | struct GNUNET_TESTBED_Operation *old_op; |
867 | 838 | ||
868 | /* We currently only get here when working on RegisteredHostContexts */ | 839 | /* We currently only get here when working on RegisteredHostContexts and |
840 | LCFContexts */ | ||
869 | GNUNET_assert (GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type); | 841 | GNUNET_assert (GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type); |
870 | rhc = event->details.operation_finished.op_cls; | 842 | rhc = event->details.operation_finished.op_cls; |
871 | GNUNET_assert (rhc->sub_op == event->details.operation_finished.operation); | 843 | if (CLOSURE_TYPE_RHC == rhc->type) |
872 | switch (rhc->state) | 844 | { |
873 | { | 845 | GNUNET_assert (rhc->sub_op == event->details.operation_finished.operation); |
874 | case RHC_GET_CFG: | 846 | switch (rhc->state) |
875 | cfg = event->details.operation_finished.generic; | 847 | { |
876 | old_op = rhc->sub_op; | 848 | case RHC_GET_CFG: |
877 | rhc->state = RHC_LINK; | 849 | cfg = event->details.operation_finished.generic; |
878 | rhc->sub_op = | 850 | old_op = rhc->sub_op; |
879 | GNUNET_TESTBED_controller_link (rhc, rhc->gateway->controller, | 851 | rhc->state = RHC_LINK; |
880 | rhc->reg_host, rhc->host, cfg, | 852 | rhc->sub_op = |
881 | GNUNET_NO); | 853 | GNUNET_TESTBED_controller_link (rhc, rhc->gateway->controller, |
882 | GNUNET_TESTBED_operation_done (old_op); | 854 | rhc->reg_host, rhc->host, cfg, |
883 | break; | 855 | GNUNET_NO); |
884 | case RHC_LINK: | 856 | GNUNET_TESTBED_operation_done (old_op); |
885 | LOG_DEBUG ("OL: Linking controllers successfull\n"); | 857 | break; |
886 | GNUNET_TESTBED_operation_done (rhc->sub_op); | 858 | case RHC_LINK: |
887 | rhc->sub_op = NULL; | 859 | LOG_DEBUG ("OL: Linking controllers successfull\n"); |
888 | rhc->state = RHC_OL_CONNECT; | 860 | GNUNET_TESTBED_operation_done (rhc->sub_op); |
889 | GST_process_next_focc (rhc); | 861 | rhc->sub_op = NULL; |
890 | break; | 862 | rhc->state = RHC_OL_CONNECT; |
891 | default: | 863 | GST_process_next_focc (rhc); |
892 | GNUNET_assert (0); | 864 | break; |
865 | default: | ||
866 | GNUNET_assert (0); | ||
867 | } | ||
868 | return; | ||
893 | } | 869 | } |
870 | lcf = event->details.operation_finished.op_cls; | ||
871 | if (CLOSURE_TYPE_LCF == lcf->type) | ||
872 | { | ||
873 | GNUNET_assert (lcf->op == event->details.operation_finished.operation); | ||
874 | GNUNET_assert (FINISHED == lcf->state); | ||
875 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != lcf->timeout_task); | ||
876 | GNUNET_SCHEDULER_cancel (lcf->timeout_task); | ||
877 | if (NULL == event->details.operation_finished.emsg) | ||
878 | send_controller_link_response (lcf->client, lcf->operation_id, | ||
879 | GNUNET_TESTBED_host_get_cfg_ | ||
880 | (GST_host_list[lcf->delegated_host_id]), | ||
881 | NULL); | ||
882 | else | ||
883 | send_controller_link_response (lcf->client, lcf->operation_id, | ||
884 | NULL, | ||
885 | event->details.operation_finished.emsg); | ||
886 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | ||
887 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | ||
888 | return; | ||
889 | } | ||
890 | GNUNET_assert (0); | ||
894 | } | 891 | } |
895 | 892 | ||
896 | 893 | ||
@@ -915,8 +912,6 @@ slave_status_callback (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
915 | { | 912 | { |
916 | slave->controller_proc = NULL; | 913 | slave->controller_proc = NULL; |
917 | GST_slave_list[slave->host_id] = NULL; | 914 | GST_slave_list[slave->host_id] = NULL; |
918 | if (NULL != slave->cfg) | ||
919 | GNUNET_CONFIGURATION_destroy (slave->cfg); | ||
920 | GNUNET_free (slave); | 915 | GNUNET_free (slave); |
921 | slave = NULL; | 916 | slave = NULL; |
922 | LOG (GNUNET_ERROR_TYPE_WARNING, "Unexpected slave shutdown\n"); | 917 | LOG (GNUNET_ERROR_TYPE_WARNING, "Unexpected slave shutdown\n"); |
@@ -930,7 +925,6 @@ slave_status_callback (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
930 | if (NULL != slave->controller) | 925 | if (NULL != slave->controller) |
931 | { | 926 | { |
932 | send_controller_link_response (lcc->client, lcc->operation_id, cfg, NULL); | 927 | send_controller_link_response (lcc->client, lcc->operation_id, cfg, NULL); |
933 | slave->cfg = GNUNET_CONFIGURATION_dup (cfg); | ||
934 | } | 928 | } |
935 | else | 929 | else |
936 | { | 930 | { |
@@ -1235,9 +1229,6 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, | |||
1235 | struct LCFContextQueue *lcfq; | 1229 | struct LCFContextQueue *lcfq; |
1236 | struct Route *route; | 1230 | struct Route *route; |
1237 | struct Route *new_route; | 1231 | struct Route *new_route; |
1238 | char *config; | ||
1239 | uLongf dest_size; | ||
1240 | size_t config_size; | ||
1241 | uint32_t delegated_host_id; | 1232 | uint32_t delegated_host_id; |
1242 | uint32_t slave_host_id; | 1233 | uint32_t slave_host_id; |
1243 | uint16_t msize; | 1234 | uint16_t msize; |
@@ -1287,53 +1278,22 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, | |||
1287 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1278 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1288 | return; | 1279 | return; |
1289 | } | 1280 | } |
1290 | 1281 | cfg = GNUNET_TESTBED_extract_config_ (message); /* destroy cfg here or in lcfcontext */ | |
1282 | if (NULL == cfg) | ||
1283 | { | ||
1284 | GNUNET_break (0); /* Configuration parsing error */ | ||
1285 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1286 | return; | ||
1287 | } | ||
1291 | if (slave_host_id == GST_context->host_id) /* Link from us */ | 1288 | if (slave_host_id == GST_context->host_id) /* Link from us */ |
1292 | { | 1289 | { |
1293 | struct Slave *slave; | 1290 | struct Slave *slave; |
1294 | struct LinkControllersContext *lcc; | 1291 | struct LinkControllersContext *lcc; |
1295 | 1292 | ||
1296 | msize -= sizeof (struct GNUNET_TESTBED_ControllerLinkRequest); | ||
1297 | config_size = ntohs (msg->config_size); | ||
1298 | if ((delegated_host_id < GST_slave_list_size) && (NULL != GST_slave_list[delegated_host_id])) /* We have already added */ | ||
1299 | { | ||
1300 | LOG (GNUNET_ERROR_TYPE_WARNING, "Host %u already connected\n", | ||
1301 | delegated_host_id); | ||
1302 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1303 | return; | ||
1304 | } | ||
1305 | config = GNUNET_malloc (config_size); | ||
1306 | dest_size = (uLongf) config_size; | ||
1307 | if (Z_OK != | ||
1308 | uncompress ((Bytef *) config, &dest_size, (const Bytef *) &msg[1], | ||
1309 | (uLong) msize)) | ||
1310 | { | ||
1311 | GNUNET_break (0); /* Compression error */ | ||
1312 | GNUNET_free (config); | ||
1313 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1314 | return; | ||
1315 | } | ||
1316 | if (config_size != dest_size) | ||
1317 | { | ||
1318 | LOG (GNUNET_ERROR_TYPE_WARNING, "Uncompressed config size mismatch\n"); | ||
1319 | GNUNET_free (config); | ||
1320 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1321 | return; | ||
1322 | } | ||
1323 | cfg = GNUNET_CONFIGURATION_create (); /* Free here or in lcfcontext */ | ||
1324 | if (GNUNET_OK != | ||
1325 | GNUNET_CONFIGURATION_deserialize (cfg, config, config_size, GNUNET_NO)) | ||
1326 | { | ||
1327 | GNUNET_break (0); /* Configuration parsing error */ | ||
1328 | GNUNET_free (config); | ||
1329 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1330 | return; | ||
1331 | } | ||
1332 | GNUNET_free (config); | ||
1333 | if ((delegated_host_id < GST_slave_list_size) && | 1293 | if ((delegated_host_id < GST_slave_list_size) && |
1334 | (NULL != GST_slave_list[delegated_host_id])) | 1294 | (NULL != GST_slave_list[delegated_host_id])) |
1335 | { | 1295 | { |
1336 | GNUNET_break (0); /* Configuration parsing error */ | 1296 | GNUNET_break (0); |
1337 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1297 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1338 | return; | 1298 | return; |
1339 | } | 1299 | } |
@@ -1347,7 +1307,6 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, | |||
1347 | GNUNET_TESTBED_controller_connect (cfg, GST_host_list[slave->host_id], | 1307 | GNUNET_TESTBED_controller_connect (cfg, GST_host_list[slave->host_id], |
1348 | event_mask, &slave_event_callback, | 1308 | event_mask, &slave_event_callback, |
1349 | slave); | 1309 | slave); |
1350 | slave->cfg = cfg; | ||
1351 | if (NULL != slave->controller) | 1310 | if (NULL != slave->controller) |
1352 | send_controller_link_response (client, | 1311 | send_controller_link_response (client, |
1353 | GNUNET_ntohll (msg->operation_id), | 1312 | GNUNET_ntohll (msg->operation_id), |
@@ -1387,17 +1346,18 @@ handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, | |||
1387 | } | 1346 | } |
1388 | lcfq = GNUNET_malloc (sizeof (struct LCFContextQueue)); | 1347 | lcfq = GNUNET_malloc (sizeof (struct LCFContextQueue)); |
1389 | lcfq->lcf = GNUNET_malloc (sizeof (struct LCFContext)); | 1348 | lcfq->lcf = GNUNET_malloc (sizeof (struct LCFContext)); |
1349 | lcfq->lcf->type = CLOSURE_TYPE_LCF; | ||
1390 | lcfq->lcf->delegated_host_id = delegated_host_id; | 1350 | lcfq->lcf->delegated_host_id = delegated_host_id; |
1391 | lcfq->lcf->slave_host_id = slave_host_id; | 1351 | lcfq->lcf->slave_host_id = slave_host_id; |
1392 | route = GST_find_dest_route (slave_host_id); | 1352 | route = GST_find_dest_route (slave_host_id); |
1393 | GNUNET_assert (NULL != route); /* because we add routes carefully */ | 1353 | GNUNET_assert (NULL != route); /* because we add routes carefully */ |
1394 | GNUNET_assert (route->dest < GST_slave_list_size); | 1354 | GNUNET_assert (route->dest < GST_slave_list_size); |
1395 | GNUNET_assert (NULL != GST_slave_list[route->dest]); | 1355 | GNUNET_assert (NULL != GST_slave_list[route->dest]); |
1356 | lcfq->lcf->cfg = cfg; | ||
1357 | lcfq->lcf->is_subordinate = msg->is_subordinate; | ||
1396 | lcfq->lcf->state = INIT; | 1358 | lcfq->lcf->state = INIT; |
1397 | lcfq->lcf->operation_id = GNUNET_ntohll (msg->operation_id); | 1359 | lcfq->lcf->operation_id = GNUNET_ntohll (msg->operation_id); |
1398 | lcfq->lcf->gateway = GST_slave_list[route->dest]; | 1360 | lcfq->lcf->gateway = GST_slave_list[route->dest]; |
1399 | lcfq->lcf->msg = GNUNET_malloc (msize); | ||
1400 | (void) memcpy (lcfq->lcf->msg, msg, msize); | ||
1401 | GNUNET_SERVER_client_keep (client); | 1361 | GNUNET_SERVER_client_keep (client); |
1402 | lcfq->lcf->client = client; | 1362 | lcfq->lcf->client = client; |
1403 | if (NULL == lcfq_head) | 1363 | if (NULL == lcfq_head) |
@@ -1969,6 +1929,7 @@ handle_slave_get_config (void *cls, struct GNUNET_SERVER_Client *client, | |||
1969 | struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg; | 1929 | struct GNUNET_TESTBED_SlaveGetConfigurationMessage *msg; |
1970 | struct Slave *slave; | 1930 | struct Slave *slave; |
1971 | struct GNUNET_TESTBED_SlaveConfiguration *reply; | 1931 | struct GNUNET_TESTBED_SlaveConfiguration *reply; |
1932 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
1972 | char *config; | 1933 | char *config; |
1973 | char *xconfig; | 1934 | char *xconfig; |
1974 | size_t config_size; | 1935 | size_t config_size; |
@@ -1988,14 +1949,8 @@ handle_slave_get_config (void *cls, struct GNUNET_SERVER_Client *client, | |||
1988 | return; | 1949 | return; |
1989 | } | 1950 | } |
1990 | slave = GST_slave_list[slave_id]; | 1951 | slave = GST_slave_list[slave_id]; |
1991 | if (NULL == slave->cfg) | 1952 | GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (GST_host_list[slave->host_id]))); |
1992 | { | 1953 | config = GNUNET_CONFIGURATION_serialize (cfg, &config_size); |
1993 | GST_send_operation_fail_msg (client, op_id, | ||
1994 | "Configuration not found (slave not started by me)"); | ||
1995 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1996 | return; | ||
1997 | } | ||
1998 | config = GNUNET_CONFIGURATION_serialize (slave->cfg, &config_size); | ||
1999 | xconfig_size = | 1954 | xconfig_size = |
2000 | GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); | 1955 | GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); |
2001 | GNUNET_free (config); | 1956 | GNUNET_free (config); |
@@ -2128,7 +2083,9 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2128 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); | 2083 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == lcf_proc_task_id); |
2129 | for (lcfq = lcfq_head; NULL != lcfq; lcfq = lcfq_head) | 2084 | for (lcfq = lcfq_head; NULL != lcfq; lcfq = lcfq_head) |
2130 | { | 2085 | { |
2131 | GNUNET_free (lcfq->lcf->msg); | 2086 | GNUNET_SERVER_client_drop (lcfq->lcf->client); |
2087 | GNUNET_assert (NULL != lcfq->lcf->cfg); | ||
2088 | GNUNET_CONFIGURATION_destroy (lcfq->lcf->cfg); | ||
2132 | GNUNET_free (lcfq->lcf); | 2089 | GNUNET_free (lcfq->lcf); |
2133 | GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq); | 2090 | GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq); |
2134 | GNUNET_free (lcfq); | 2091 | GNUNET_free (lcfq); |
@@ -2191,8 +2148,6 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2191 | reghost_free_iterator, | 2148 | reghost_free_iterator, |
2192 | GST_slave_list[id]); | 2149 | GST_slave_list[id]); |
2193 | GNUNET_CONTAINER_multihashmap_destroy (GST_slave_list[id]->reghost_map); | 2150 | GNUNET_CONTAINER_multihashmap_destroy (GST_slave_list[id]->reghost_map); |
2194 | if (NULL != GST_slave_list[id]->cfg) | ||
2195 | GNUNET_CONFIGURATION_destroy (GST_slave_list[id]->cfg); | ||
2196 | if (NULL != GST_slave_list[id]->controller) | 2151 | if (NULL != GST_slave_list[id]->controller) |
2197 | GNUNET_TESTBED_controller_disconnect (GST_slave_list[id]->controller); | 2152 | GNUNET_TESTBED_controller_disconnect (GST_slave_list[id]->controller); |
2198 | if (NULL != GST_slave_list[id]->controller_proc) | 2153 | if (NULL != GST_slave_list[id]->controller_proc) |
diff --git a/src/testbed/gnunet-service-testbed.h b/src/testbed/gnunet-service-testbed.h index 984cf438a..37f6a6aaf 100644 --- a/src/testbed/gnunet-service-testbed.h +++ b/src/testbed/gnunet-service-testbed.h | |||
@@ -186,11 +186,6 @@ struct Slave | |||
186 | struct GNUNET_TESTBED_Controller *controller; | 186 | struct GNUNET_TESTBED_Controller *controller; |
187 | 187 | ||
188 | /** | 188 | /** |
189 | * The configuration of the slave. Cannot be NULL | ||
190 | */ | ||
191 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
192 | |||
193 | /** | ||
194 | * handle to lcc which is associated with this slave startup. Should be set to | 189 | * handle to lcc which is associated with this slave startup. Should be set to |
195 | * NULL when the slave has successfully started up | 190 | * NULL when the slave has successfully started up |
196 | */ | 191 | */ |
@@ -393,12 +388,34 @@ struct ForwardedOverlayConnectContext | |||
393 | 388 | ||
394 | 389 | ||
395 | /** | 390 | /** |
391 | * The type for data structures which commonly arrive at the slave_event_callback | ||
392 | */ | ||
393 | enum ClosureType | ||
394 | { | ||
395 | /** | ||
396 | * Type for RegisteredHostContext closures | ||
397 | */ | ||
398 | CLOSURE_TYPE_RHC = 1, | ||
399 | |||
400 | /** | ||
401 | * Type for LinkControllersForwardingContext closures | ||
402 | */ | ||
403 | CLOSURE_TYPE_LCF | ||
404 | }; | ||
405 | |||
406 | |||
407 | /** | ||
396 | * This context information will be created for each host that is registered at | 408 | * This context information will be created for each host that is registered at |
397 | * slave controllers during overlay connects. | 409 | * slave controllers during overlay connects. |
398 | */ | 410 | */ |
399 | struct RegisteredHostContext | 411 | struct RegisteredHostContext |
400 | { | 412 | { |
401 | /** | 413 | /** |
414 | * The type of this data structure. Set this to CLOSURE_TYPE_RHC | ||
415 | */ | ||
416 | enum ClosureType type; | ||
417 | |||
418 | /** | ||
402 | * The host which is being registered | 419 | * The host which is being registered |
403 | */ | 420 | */ |
404 | struct GNUNET_TESTBED_Host *reg_host; | 421 | struct GNUNET_TESTBED_Host *reg_host; |
@@ -502,14 +519,14 @@ enum LCFContextState | |||
502 | struct LCFContext | 519 | struct LCFContext |
503 | { | 520 | { |
504 | /** | 521 | /** |
505 | * The gateway which will pass the link message to delegated host | 522 | * The type of this data structure. Set this to CLOSURE_TYPE_LCF |
506 | */ | 523 | */ |
507 | struct Slave *gateway; | 524 | enum ClosureType type; |
508 | 525 | ||
509 | /** | 526 | /** |
510 | * The controller link message that has to be forwarded to | 527 | * The gateway which will pass the link message to delegated host |
511 | */ | 528 | */ |
512 | struct GNUNET_TESTBED_ControllerLinkRequest *msg; | 529 | struct Slave *gateway; |
513 | 530 | ||
514 | /** | 531 | /** |
515 | * The client which has asked to perform this operation | 532 | * The client which has asked to perform this operation |
@@ -519,12 +536,28 @@ struct LCFContext | |||
519 | /** | 536 | /** |
520 | * Handle for operations which are forwarded while linking controllers | 537 | * Handle for operations which are forwarded while linking controllers |
521 | */ | 538 | */ |
522 | struct ForwardedOperationContext *fopc; | 539 | struct GNUNET_TESTBED_Operation *op; |
540 | |||
541 | /** | ||
542 | * The configuration which has to be either used as a template while starting | ||
543 | * the delegated controller or for connecting to the delegated controller | ||
544 | */ | ||
545 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
546 | |||
547 | /** | ||
548 | * The timeout task | ||
549 | */ | ||
550 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | ||
523 | 551 | ||
524 | /** | 552 | /** |
525 | * The id of the operation which created this context | 553 | * The id of the operation which created this context |
526 | */ | 554 | */ |
527 | uint64_t operation_id; | 555 | uint64_t operation_id; |
556 | |||
557 | /** | ||
558 | * should the slave controller start the delegated controller? | ||
559 | */ | ||
560 | int is_subordinate; | ||
528 | 561 | ||
529 | /** | 562 | /** |
530 | * The state of this context | 563 | * The state of this context |
@@ -565,6 +598,7 @@ struct LCFContextQueue | |||
565 | struct LCFContextQueue *prev; | 598 | struct LCFContextQueue *prev; |
566 | }; | 599 | }; |
567 | 600 | ||
601 | |||
568 | /** | 602 | /** |
569 | * Our configuration | 603 | * Our configuration |
570 | */ | 604 | */ |
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c index 8bed69f36..cfd5d9038 100644 --- a/src/testbed/gnunet-service-testbed_oc.c +++ b/src/testbed/gnunet-service-testbed_oc.c | |||
@@ -989,7 +989,7 @@ overlay_connect_get_config (void *cls, const struct GNUNET_MessageHeader *msg) | |||
989 | 989 | ||
990 | 990 | ||
991 | /** | 991 | /** |
992 | * Callback which will be called to after a host registration succeeded or failed | 992 | * Callback which will be called after a host registration succeeded or failed |
993 | * | 993 | * |
994 | * @param cls the RegisteredHostContext | 994 | * @param cls the RegisteredHostContext |
995 | * @param emsg the error message; NULL if host registration is successful | 995 | * @param emsg the error message; NULL if host registration is successful |
@@ -998,7 +998,7 @@ static void | |||
998 | registeredhost_registration_completion (void *cls, const char *emsg) | 998 | registeredhost_registration_completion (void *cls, const char *emsg) |
999 | { | 999 | { |
1000 | struct RegisteredHostContext *rhc = cls; | 1000 | struct RegisteredHostContext *rhc = cls; |
1001 | struct GNUNET_CONFIGURATION_Handle *cfg; | 1001 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
1002 | uint32_t peer2_host_id; | 1002 | uint32_t peer2_host_id; |
1003 | 1003 | ||
1004 | /* if (NULL != rhc->focc_dll_head) */ | 1004 | /* if (NULL != rhc->focc_dll_head) */ |
@@ -1006,13 +1006,14 @@ registeredhost_registration_completion (void *cls, const char *emsg) | |||
1006 | peer2_host_id = GNUNET_TESTBED_host_get_id_ (rhc->reg_host); | 1006 | peer2_host_id = GNUNET_TESTBED_host_get_id_ (rhc->reg_host); |
1007 | GNUNET_assert (RHC_INIT == rhc->state); | 1007 | GNUNET_assert (RHC_INIT == rhc->state); |
1008 | GNUNET_assert (NULL == rhc->sub_op); | 1008 | GNUNET_assert (NULL == rhc->sub_op); |
1009 | if ((NULL == rhc->gateway2) || ((peer2_host_id < GST_slave_list_size) /* Check if we have the needed config */ | 1009 | if ((NULL == rhc->gateway2) || ((peer2_host_id < GST_host_list_size) /* Check if we have the needed config */ |
1010 | && (NULL != GST_slave_list[peer2_host_id]))) | 1010 | && (NULL != GST_host_list[peer2_host_id]))) |
1011 | { | 1011 | { |
1012 | rhc->state = RHC_LINK; | 1012 | rhc->state = RHC_LINK; |
1013 | cfg = | 1013 | cfg = |
1014 | (NULL == | 1014 | (NULL == |
1015 | rhc->gateway2) ? our_config : GST_slave_list[peer2_host_id]->cfg; | 1015 | rhc->gateway2) ? our_config |
1016 | : GNUNET_TESTBED_host_get_cfg_ (GST_host_list[peer2_host_id]); | ||
1016 | rhc->sub_op = | 1017 | rhc->sub_op = |
1017 | GNUNET_TESTBED_controller_link (rhc, rhc->gateway->controller, | 1018 | GNUNET_TESTBED_controller_link (rhc, rhc->gateway->controller, |
1018 | rhc->reg_host, rhc->host, cfg, | 1019 | rhc->reg_host, rhc->host, cfg, |
@@ -1145,6 +1146,7 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1145 | int skip_focc; | 1146 | int skip_focc; |
1146 | 1147 | ||
1147 | rhc = GNUNET_malloc (sizeof (struct RegisteredHostContext)); | 1148 | rhc = GNUNET_malloc (sizeof (struct RegisteredHostContext)); |
1149 | rhc->type = CLOSURE_TYPE_RHC; | ||
1148 | if (NULL != route_to_peer2_host) | 1150 | if (NULL != route_to_peer2_host) |
1149 | rhc->reg_host = GST_host_list[route_to_peer2_host->dest]; | 1151 | rhc->reg_host = GST_host_list[route_to_peer2_host->dest]; |
1150 | else | 1152 | else |
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 6fd05e657..4ea21b3a6 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c | |||
@@ -1581,6 +1581,7 @@ GNUNET_TESTBED_controller_link (void *op_cls, | |||
1581 | uint32_t slave_host_id; | 1581 | uint32_t slave_host_id; |
1582 | uint32_t delegated_host_id; | 1582 | uint32_t delegated_host_id; |
1583 | 1583 | ||
1584 | |||
1584 | GNUNET_assert (GNUNET_YES == | 1585 | GNUNET_assert (GNUNET_YES == |
1585 | GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); | 1586 | GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); |
1586 | slave_host_id = | 1587 | slave_host_id = |
@@ -1591,7 +1592,8 @@ GNUNET_TESTBED_controller_link (void *op_cls, | |||
1591 | GNUNET_assert (GNUNET_YES == | 1592 | GNUNET_assert (GNUNET_YES == |
1592 | GNUNET_TESTBED_is_host_registered_ (slave_host, master)); | 1593 | GNUNET_TESTBED_is_host_registered_ (slave_host, master)); |
1593 | return GNUNET_TESTBED_controller_link_ (op_cls, master, delegated_host_id, | 1594 | return GNUNET_TESTBED_controller_link_ (op_cls, master, delegated_host_id, |
1594 | slave_host_id, slave_cfg, | 1595 | slave_host_id, |
1596 | GNUNET_TESTBED_host_get_cfg_ (delegated_host), | ||
1595 | is_subordinate); | 1597 | is_subordinate); |
1596 | 1598 | ||
1597 | } | 1599 | } |
@@ -1776,7 +1778,8 @@ GNUNET_TESTBED_operation_done (struct GNUNET_TESTBED_Operation *operation) | |||
1776 | * GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONFIGURATION, | 1778 | * GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONFIGURATION, |
1777 | * GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, | 1779 | * GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION, |
1778 | * GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, | 1780 | * GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST, |
1779 | * GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT | 1781 | * GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS, |
1782 | * GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT, | ||
1780 | * | 1783 | * |
1781 | * @param msg the message containing compressed configuration | 1784 | * @param msg the message containing compressed configuration |
1782 | * @return handle to the parsed configuration; NULL upon error while parsing the message | 1785 | * @return handle to the parsed configuration; NULL upon error while parsing the message |
@@ -1842,6 +1845,16 @@ GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg) | |||
1842 | xdata = (const Bytef *) &imsg[1]; | 1845 | xdata = (const Bytef *) &imsg[1]; |
1843 | } | 1846 | } |
1844 | break; | 1847 | break; |
1848 | case GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS: | ||
1849 | { | ||
1850 | const struct GNUNET_TESTBED_ControllerLinkRequest *imsg; | ||
1851 | imsg = (const struct GNUNET_TESTBED_ControllerLinkRequest *) msg; | ||
1852 | data_len = ntohs (imsg->config_size); | ||
1853 | xdata_len = ntohs (imsg->header.size) - sizeof (const struct | ||
1854 | GNUNET_TESTBED_ControllerLinkRequest); | ||
1855 | xdata = (const Bytef *) &imsg[1]; | ||
1856 | } | ||
1857 | break; | ||
1845 | default: | 1858 | default: |
1846 | GNUNET_assert (0); | 1859 | GNUNET_assert (0); |
1847 | } | 1860 | } |
@@ -1849,13 +1862,19 @@ GNUNET_TESTBED_extract_config_ (const struct GNUNET_MessageHeader *msg) | |||
1849 | if (Z_OK != (ret = uncompress (data, &data_len, xdata, xdata_len))) | 1862 | if (Z_OK != (ret = uncompress (data, &data_len, xdata, xdata_len))) |
1850 | { | 1863 | { |
1851 | GNUNET_free (data); | 1864 | GNUNET_free (data); |
1865 | GNUNET_break_op (0); | ||
1852 | return NULL; | 1866 | return NULL; |
1853 | } | 1867 | } |
1854 | cfg = GNUNET_CONFIGURATION_create (); | 1868 | cfg = GNUNET_CONFIGURATION_create (); |
1855 | GNUNET_assert (GNUNET_OK == | 1869 | if (GNUNET_OK != |
1856 | GNUNET_CONFIGURATION_deserialize (cfg, (const char *) data, | 1870 | GNUNET_CONFIGURATION_deserialize (cfg, (const char *) data, |
1857 | (size_t) data_len, | 1871 | (size_t) data_len, |
1858 | GNUNET_NO)); | 1872 | GNUNET_NO)) |
1873 | { | ||
1874 | GNUNET_free (data); | ||
1875 | GNUNET_break_op (0); | ||
1876 | return NULL; | ||
1877 | } | ||
1859 | GNUNET_free (data); | 1878 | GNUNET_free (data); |
1860 | return cfg; | 1879 | return cfg; |
1861 | } | 1880 | } |