diff options
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/set_api.c | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/src/set/set_api.c b/src/set/set_api.c index 343b5f881..826b6a63c 100644 --- a/src/set/set_api.c +++ b/src/set/set_api.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_protocols.h" | 28 | #include "gnunet_protocols.h" |
29 | #include "gnunet_client_lib.h" | ||
30 | #include "gnunet_set_service.h" | 29 | #include "gnunet_set_service.h" |
31 | #include "set.h" | 30 | #include "set.h" |
32 | 31 | ||
@@ -50,11 +49,6 @@ struct SetCopyRequest | |||
50 | struct GNUNET_SET_Handle | 49 | struct GNUNET_SET_Handle |
51 | { | 50 | { |
52 | /** | 51 | /** |
53 | * Client connected to the set service. | ||
54 | */ | ||
55 | struct GNUNET_CLIENT_Connection *client; | ||
56 | |||
57 | /** | ||
58 | * Message queue for @e client. | 52 | * Message queue for @e client. |
59 | */ | 53 | */ |
60 | struct GNUNET_MQ_Handle *mq; | 54 | struct GNUNET_MQ_Handle *mq; |
@@ -189,10 +183,6 @@ struct GNUNET_SET_OperationHandle | |||
189 | */ | 183 | */ |
190 | struct GNUNET_SET_ListenHandle | 184 | struct GNUNET_SET_ListenHandle |
191 | { | 185 | { |
192 | /** | ||
193 | * Connection to the service. | ||
194 | */ | ||
195 | struct GNUNET_CLIENT_Connection *client; | ||
196 | 186 | ||
197 | /** | 187 | /** |
198 | * Message queue for the client. | 188 | * Message queue for the client. |
@@ -298,7 +288,7 @@ check_iter_element (void *cls, | |||
298 | /* minimum size was already checked, everything else is OK! */ | 288 | /* minimum size was already checked, everything else is OK! */ |
299 | return GNUNET_OK; | 289 | return GNUNET_OK; |
300 | } | 290 | } |
301 | 291 | ||
302 | 292 | ||
303 | /** | 293 | /** |
304 | * Handle element for iteration over the set. Notifies the | 294 | * Handle element for iteration over the set. Notifies the |
@@ -313,7 +303,7 @@ check_iter_element (void *cls, | |||
313 | { | 303 | { |
314 | struct GNUNET_SET_Handle *set = cls; | 304 | struct GNUNET_SET_Handle *set = cls; |
315 | GNUNET_SET_ElementIterator iter = set->iterator; | 305 | GNUNET_SET_ElementIterator iter = set->iterator; |
316 | struct GNUNET_SET_Element element; | 306 | struct GNUNET_SET_Element element; |
317 | struct GNUNET_SET_IterAckMessage *ack_msg; | 307 | struct GNUNET_SET_IterAckMessage *ack_msg; |
318 | struct GNUNET_MQ_Envelope *ev; | 308 | struct GNUNET_MQ_Envelope *ev; |
319 | uint16_t msize; | 309 | uint16_t msize; |
@@ -534,7 +524,7 @@ handle_client_set_error (void *cls, | |||
534 | { | 524 | { |
535 | struct GNUNET_SET_Handle *set = cls; | 525 | struct GNUNET_SET_Handle *set = cls; |
536 | GNUNET_SET_ElementIterator iter = set->iterator; | 526 | GNUNET_SET_ElementIterator iter = set->iterator; |
537 | 527 | ||
538 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 528 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
539 | "Handling client set error %d\n", | 529 | "Handling client set error %d\n", |
540 | error); | 530 | error); |
@@ -589,15 +579,16 @@ create_internal (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
589 | struct GNUNET_MQ_Envelope *mqm; | 579 | struct GNUNET_MQ_Envelope *mqm; |
590 | struct GNUNET_SET_CreateMessage *create_msg; | 580 | struct GNUNET_SET_CreateMessage *create_msg; |
591 | struct GNUNET_SET_CopyLazyConnectMessage *copy_msg; | 581 | struct GNUNET_SET_CopyLazyConnectMessage *copy_msg; |
582 | struct GNUNET_CLIENT_Connection *client; | ||
592 | 583 | ||
593 | set->cfg = cfg; | 584 | set->cfg = cfg; |
594 | set->client = GNUNET_CLIENT_connect ("set", cfg); | 585 | client = GNUNET_CLIENT_connect ("set", cfg); |
595 | if (NULL == set->client) | 586 | if (NULL == client) |
596 | { | 587 | { |
597 | GNUNET_free (set); | 588 | GNUNET_free (set); |
598 | return NULL; | 589 | return NULL; |
599 | } | 590 | } |
600 | set->mq = GNUNET_MQ_queue_for_connection_client (set->client, | 591 | set->mq = GNUNET_MQ_queue_for_connection_client (client, |
601 | mq_handlers, | 592 | mq_handlers, |
602 | &handle_client_set_error, | 593 | &handle_client_set_error, |
603 | set); | 594 | set); |
@@ -750,11 +741,6 @@ GNUNET_SET_destroy (struct GNUNET_SET_Handle *set) | |||
750 | } | 741 | } |
751 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 742 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
752 | "Really destroying set\n"); | 743 | "Really destroying set\n"); |
753 | if (NULL != set->client) | ||
754 | { | ||
755 | GNUNET_CLIENT_disconnect (set->client); | ||
756 | set->client = NULL; | ||
757 | } | ||
758 | if (NULL != set->mq) | 744 | if (NULL != set->mq) |
759 | { | 745 | { |
760 | GNUNET_MQ_destroy (set->mq); | 746 | GNUNET_MQ_destroy (set->mq); |
@@ -893,8 +879,6 @@ handle_client_listener_error (void *cls, | |||
893 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 879 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
894 | "Listener broke down (%d), re-connecting\n", | 880 | "Listener broke down (%d), re-connecting\n", |
895 | (int) error); | 881 | (int) error); |
896 | GNUNET_CLIENT_disconnect (lh->client); | ||
897 | lh->client = NULL; | ||
898 | GNUNET_MQ_destroy (lh->mq); | 882 | GNUNET_MQ_destroy (lh->mq); |
899 | lh->mq = NULL; | 883 | lh->mq = NULL; |
900 | lh->reconnect_task = GNUNET_SCHEDULER_add_delayed (lh->reconnect_backoff, | 884 | lh->reconnect_task = GNUNET_SCHEDULER_add_delayed (lh->reconnect_backoff, |
@@ -911,7 +895,7 @@ handle_client_listener_error (void *cls, | |||
911 | */ | 895 | */ |
912 | static void | 896 | static void |
913 | listen_connect (void *cls) | 897 | listen_connect (void *cls) |
914 | { | 898 | { |
915 | GNUNET_MQ_hd_var_size (request, | 899 | GNUNET_MQ_hd_var_size (request, |
916 | GNUNET_MESSAGE_TYPE_SET_REQUEST, | 900 | GNUNET_MESSAGE_TYPE_SET_REQUEST, |
917 | struct GNUNET_SET_RequestMessage); | 901 | struct GNUNET_SET_RequestMessage); |
@@ -922,14 +906,14 @@ listen_connect (void *cls) | |||
922 | }; | 906 | }; |
923 | struct GNUNET_MQ_Envelope *mqm; | 907 | struct GNUNET_MQ_Envelope *mqm; |
924 | struct GNUNET_SET_ListenMessage *msg; | 908 | struct GNUNET_SET_ListenMessage *msg; |
909 | struct GNUNET_CLIENT_Connection *client; | ||
925 | 910 | ||
926 | lh->reconnect_task = NULL; | 911 | lh->reconnect_task = NULL; |
927 | GNUNET_assert (NULL == lh->client); | ||
928 | lh->client = GNUNET_CLIENT_connect ("set", lh->cfg); | ||
929 | if (NULL == lh->client) | ||
930 | return; | ||
931 | GNUNET_assert (NULL == lh->mq); | 912 | GNUNET_assert (NULL == lh->mq); |
932 | lh->mq = GNUNET_MQ_queue_for_connection_client (lh->client, | 913 | client = GNUNET_CLIENT_connect ("set", lh->cfg); |
914 | if (NULL == client) | ||
915 | return; | ||
916 | lh->mq = GNUNET_MQ_queue_for_connection_client (client, | ||
933 | mq_handlers, | 917 | mq_handlers, |
934 | &handle_client_listener_error, | 918 | &handle_client_listener_error, |
935 | lh); | 919 | lh); |
@@ -969,7 +953,7 @@ GNUNET_SET_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
969 | lh->app_id = *app_id; | 953 | lh->app_id = *app_id; |
970 | lh->reconnect_backoff = GNUNET_TIME_UNIT_MILLISECONDS; | 954 | lh->reconnect_backoff = GNUNET_TIME_UNIT_MILLISECONDS; |
971 | listen_connect (lh); | 955 | listen_connect (lh); |
972 | if (NULL == lh->client) | 956 | if (NULL == lh->mq) |
973 | { | 957 | { |
974 | GNUNET_free (lh); | 958 | GNUNET_free (lh); |
975 | return NULL; | 959 | return NULL; |
@@ -993,11 +977,6 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh) | |||
993 | GNUNET_MQ_destroy (lh->mq); | 977 | GNUNET_MQ_destroy (lh->mq); |
994 | lh->mq = NULL; | 978 | lh->mq = NULL; |
995 | } | 979 | } |
996 | if (NULL != lh->client) | ||
997 | { | ||
998 | GNUNET_CLIENT_disconnect (lh->client); | ||
999 | lh->client = NULL; | ||
1000 | } | ||
1001 | if (NULL != lh->reconnect_task) | 980 | if (NULL != lh->reconnect_task) |
1002 | { | 981 | { |
1003 | GNUNET_SCHEDULER_cancel (lh->reconnect_task); | 982 | GNUNET_SCHEDULER_cancel (lh->reconnect_task); |