diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-19 18:50:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-19 18:50:00 +0000 |
commit | 2042d867f71e3cb1d7ade6b3d474ce0c1f5f87bd (patch) | |
tree | 58be8b2e7321a91015df8ab3281a9f89a26cec1f /src/consensus/consensus_api.c | |
parent | d8d3021ad9af2abe551fd6cd0fe2529a99d3683c (diff) | |
download | gnunet-2042d867f71e3cb1d7ade6b3d474ce0c1f5f87bd.tar.gz gnunet-2042d867f71e3cb1d7ade6b3d474ce0c1f5f87bd.zip |
redefine GNUNET_MQ_queue_for_connection_client to capture client handle
Diffstat (limited to 'src/consensus/consensus_api.c')
-rw-r--r-- | src/consensus/consensus_api.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/consensus/consensus_api.c b/src/consensus/consensus_api.c index 16096c28c..8653621ec 100644 --- a/src/consensus/consensus_api.c +++ b/src/consensus/consensus_api.c | |||
@@ -45,17 +45,12 @@ struct GNUNET_CONSENSUS_Handle | |||
45 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 45 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Client connected to the consensus service, may be NULL if not connected. | ||
49 | */ | ||
50 | struct GNUNET_CLIENT_Connection *client; | ||
51 | |||
52 | /** | ||
53 | * Callback for new elements. Not called for elements added locally. | 48 | * Callback for new elements. Not called for elements added locally. |
54 | */ | 49 | */ |
55 | GNUNET_CONSENSUS_ElementCallback new_element_cb; | 50 | GNUNET_CONSENSUS_ElementCallback new_element_cb; |
56 | 51 | ||
57 | /** | 52 | /** |
58 | * Closure for new_element_cb | 53 | * Closure for @e new_element_cb |
59 | */ | 54 | */ |
60 | void *new_element_cls; | 55 | void *new_element_cls; |
61 | 56 | ||
@@ -75,7 +70,7 @@ struct GNUNET_CONSENSUS_Handle | |||
75 | GNUNET_CONSENSUS_ConcludeCallback conclude_cb; | 70 | GNUNET_CONSENSUS_ConcludeCallback conclude_cb; |
76 | 71 | ||
77 | /** | 72 | /** |
78 | * Closure for the conclude callback. | 73 | * Closure for the @e conclude_cb callback. |
79 | */ | 74 | */ |
80 | void *conclude_cls; | 75 | void *conclude_cls; |
81 | 76 | ||
@@ -156,8 +151,6 @@ handle_conclude_done (void *cls, | |||
156 | 151 | ||
157 | GNUNET_MQ_destroy (consensus->mq); | 152 | GNUNET_MQ_destroy (consensus->mq); |
158 | consensus->mq = NULL; | 153 | consensus->mq = NULL; |
159 | GNUNET_CLIENT_disconnect (consensus->client); | ||
160 | consensus->client = NULL; | ||
161 | GNUNET_assert (NULL != (cc = consensus->conclude_cb)); | 154 | GNUNET_assert (NULL != (cc = consensus->conclude_cb)); |
162 | consensus->conclude_cb = NULL; | 155 | consensus->conclude_cb = NULL; |
163 | cc (consensus->conclude_cls); | 156 | cc (consensus->conclude_cls); |
@@ -224,17 +217,22 @@ GNUNET_CONSENSUS_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
224 | }; | 217 | }; |
225 | struct GNUNET_CONSENSUS_JoinMessage *join_msg; | 218 | struct GNUNET_CONSENSUS_JoinMessage *join_msg; |
226 | struct GNUNET_MQ_Envelope *ev; | 219 | struct GNUNET_MQ_Envelope *ev; |
220 | struct GNUNET_CLIENT_Connection *client; | ||
227 | 221 | ||
228 | consensus->cfg = cfg; | 222 | consensus->cfg = cfg; |
229 | consensus->new_element_cb = new_element_cb; | 223 | consensus->new_element_cb = new_element_cb; |
230 | consensus->new_element_cls = new_element_cls; | 224 | consensus->new_element_cls = new_element_cls; |
231 | consensus->session_id = *session_id; | 225 | consensus->session_id = *session_id; |
232 | consensus->client = GNUNET_CLIENT_connect ("consensus", cfg); | 226 | client = GNUNET_CLIENT_connect ("consensus", cfg); |
233 | consensus->mq = GNUNET_MQ_queue_for_connection_client (consensus->client, | 227 | if (NULL == client) |
234 | mq_handlers, mq_error_handler, consensus); | 228 | { |
235 | 229 | GNUNET_free (consensus); | |
236 | GNUNET_assert (consensus->client != NULL); | 230 | return NULL; |
237 | 231 | } | |
232 | consensus->mq = GNUNET_MQ_queue_for_connection_client (client, | ||
233 | mq_handlers, | ||
234 | &mq_error_handler, | ||
235 | consensus); | ||
238 | ev = GNUNET_MQ_msg_extra (join_msg, | 236 | ev = GNUNET_MQ_msg_extra (join_msg, |
239 | (num_peers * sizeof (struct GNUNET_PeerIdentity)), | 237 | (num_peers * sizeof (struct GNUNET_PeerIdentity)), |
240 | GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN); | 238 | GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN); |
@@ -342,10 +340,7 @@ GNUNET_CONSENSUS_destroy (struct GNUNET_CONSENSUS_Handle *consensus) | |||
342 | GNUNET_MQ_destroy (consensus->mq); | 340 | GNUNET_MQ_destroy (consensus->mq); |
343 | consensus->mq = NULL; | 341 | consensus->mq = NULL; |
344 | } | 342 | } |
345 | if (NULL != consensus->client) | ||
346 | { | ||
347 | GNUNET_CLIENT_disconnect (consensus->client); | ||
348 | consensus->client = NULL; | ||
349 | } | ||
350 | GNUNET_free (consensus); | 343 | GNUNET_free (consensus); |
351 | } | 344 | } |
345 | |||
346 | /* end of consensus_api.c */ | ||