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/ats | |
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/ats')
-rw-r--r-- | src/ats/ats_api_connectivity.c | 24 | ||||
-rw-r--r-- | src/ats/ats_api_scheduling.c | 26 |
2 files changed, 11 insertions, 39 deletions
diff --git a/src/ats/ats_api_connectivity.c b/src/ats/ats_api_connectivity.c index 1897e2783..139f50a81 100644 --- a/src/ats/ats_api_connectivity.c +++ b/src/ats/ats_api_connectivity.c | |||
@@ -72,11 +72,6 @@ struct GNUNET_ATS_ConnectivityHandle | |||
72 | struct GNUNET_CONTAINER_MultiPeerMap *sug_requests; | 72 | struct GNUNET_CONTAINER_MultiPeerMap *sug_requests; |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * Connection to ATS service. | ||
76 | */ | ||
77 | struct GNUNET_CLIENT_Connection *client; | ||
78 | |||
79 | /** | ||
80 | * Message queue for sending requests to the ATS service. | 75 | * Message queue for sending requests to the ATS service. |
81 | */ | 76 | */ |
82 | struct GNUNET_MQ_Handle *mq; | 77 | struct GNUNET_MQ_Handle *mq; |
@@ -130,11 +125,6 @@ force_reconnect (struct GNUNET_ATS_ConnectivityHandle *ch) | |||
130 | GNUNET_MQ_destroy (ch->mq); | 125 | GNUNET_MQ_destroy (ch->mq); |
131 | ch->mq = NULL; | 126 | ch->mq = NULL; |
132 | } | 127 | } |
133 | if (NULL != ch->client) | ||
134 | { | ||
135 | GNUNET_CLIENT_disconnect (ch->client); | ||
136 | ch->client = NULL; | ||
137 | } | ||
138 | ch->backoff = GNUNET_TIME_STD_BACKOFF (ch->backoff); | 128 | ch->backoff = GNUNET_TIME_STD_BACKOFF (ch->backoff); |
139 | ch->task = GNUNET_SCHEDULER_add_delayed (ch->backoff, | 129 | ch->task = GNUNET_SCHEDULER_add_delayed (ch->backoff, |
140 | &reconnect_task, | 130 | &reconnect_task, |
@@ -203,15 +193,16 @@ reconnect (struct GNUNET_ATS_ConnectivityHandle *ch) | |||
203 | { { NULL, 0, 0 } }; | 193 | { { NULL, 0, 0 } }; |
204 | struct GNUNET_MQ_Envelope *ev; | 194 | struct GNUNET_MQ_Envelope *ev; |
205 | struct ClientStartMessage *init; | 195 | struct ClientStartMessage *init; |
196 | struct GNUNET_CLIENT_Connection *client; | ||
206 | 197 | ||
207 | GNUNET_assert (NULL == ch->client); | 198 | GNUNET_assert (NULL == ch->mq); |
208 | ch->client = GNUNET_CLIENT_connect ("ats", ch->cfg); | 199 | client = GNUNET_CLIENT_connect ("ats", ch->cfg); |
209 | if (NULL == ch->client) | 200 | if (NULL == client) |
210 | { | 201 | { |
211 | force_reconnect (ch); | 202 | force_reconnect (ch); |
212 | return; | 203 | return; |
213 | } | 204 | } |
214 | ch->mq = GNUNET_MQ_queue_for_connection_client (ch->client, | 205 | ch->mq = GNUNET_MQ_queue_for_connection_client (client, |
215 | handlers, | 206 | handlers, |
216 | &error_handler, | 207 | &error_handler, |
217 | ch); | 208 | ch); |
@@ -281,11 +272,6 @@ GNUNET_ATS_connectivity_done (struct GNUNET_ATS_ConnectivityHandle *ch) | |||
281 | GNUNET_MQ_destroy (ch->mq); | 272 | GNUNET_MQ_destroy (ch->mq); |
282 | ch->mq = NULL; | 273 | ch->mq = NULL; |
283 | } | 274 | } |
284 | if (NULL != ch->client) | ||
285 | { | ||
286 | GNUNET_CLIENT_disconnect (ch->client); | ||
287 | ch->client = NULL; | ||
288 | } | ||
289 | if (NULL != ch->task) | 275 | if (NULL != ch->task) |
290 | { | 276 | { |
291 | GNUNET_SCHEDULER_cancel (ch->task); | 277 | GNUNET_SCHEDULER_cancel (ch->task); |
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index bc730b248..d7e305950 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c | |||
@@ -118,11 +118,6 @@ struct GNUNET_ATS_SchedulingHandle | |||
118 | void *suggest_cb_cls; | 118 | void *suggest_cb_cls; |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * Connection to ATS service. | ||
122 | */ | ||
123 | struct GNUNET_CLIENT_Connection *client; | ||
124 | |||
125 | /** | ||
126 | * Message queue for sending requests to the ATS service. | 121 | * Message queue for sending requests to the ATS service. |
127 | */ | 122 | */ |
128 | struct GNUNET_MQ_Handle *mq; | 123 | struct GNUNET_MQ_Handle *mq; |
@@ -190,11 +185,6 @@ force_reconnect (struct GNUNET_ATS_SchedulingHandle *sh) | |||
190 | GNUNET_MQ_destroy (sh->mq); | 185 | GNUNET_MQ_destroy (sh->mq); |
191 | sh->mq = NULL; | 186 | sh->mq = NULL; |
192 | } | 187 | } |
193 | if (NULL != sh->client) | ||
194 | { | ||
195 | GNUNET_CLIENT_disconnect (sh->client); | ||
196 | sh->client = NULL; | ||
197 | } | ||
198 | sh->suggest_cb (sh->suggest_cb_cls, | 188 | sh->suggest_cb (sh->suggest_cb_cls, |
199 | NULL, NULL, NULL, | 189 | NULL, NULL, NULL, |
200 | GNUNET_BANDWIDTH_ZERO, | 190 | GNUNET_BANDWIDTH_ZERO, |
@@ -539,17 +529,18 @@ reconnect (struct GNUNET_ATS_SchedulingHandle *sh) | |||
539 | struct ClientStartMessage *init; | 529 | struct ClientStartMessage *init; |
540 | unsigned int i; | 530 | unsigned int i; |
541 | struct GNUNET_ATS_AddressRecord *ar; | 531 | struct GNUNET_ATS_AddressRecord *ar; |
532 | struct GNUNET_CLIENT_Connection *client; | ||
542 | 533 | ||
543 | GNUNET_assert (NULL == sh->client); | 534 | GNUNET_assert (NULL == sh->mq); |
544 | sh->client = GNUNET_CLIENT_connect ("ats", | 535 | client = GNUNET_CLIENT_connect ("ats", |
545 | sh->cfg); | 536 | sh->cfg); |
546 | if (NULL == sh->client) | 537 | if (NULL == client) |
547 | { | 538 | { |
548 | GNUNET_break (0); | 539 | GNUNET_break (0); |
549 | force_reconnect (sh); | 540 | force_reconnect (sh); |
550 | return; | 541 | return; |
551 | } | 542 | } |
552 | sh->mq = GNUNET_MQ_queue_for_connection_client (sh->client, | 543 | sh->mq = GNUNET_MQ_queue_for_connection_client (client, |
553 | handlers, | 544 | handlers, |
554 | &error_handler, | 545 | &error_handler, |
555 | sh); | 546 | sh); |
@@ -614,11 +605,6 @@ GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh) | |||
614 | GNUNET_MQ_destroy (sh->mq); | 605 | GNUNET_MQ_destroy (sh->mq); |
615 | sh->mq = NULL; | 606 | sh->mq = NULL; |
616 | } | 607 | } |
617 | if (NULL != sh->client) | ||
618 | { | ||
619 | GNUNET_CLIENT_disconnect (sh->client); | ||
620 | sh->client = NULL; | ||
621 | } | ||
622 | if (NULL != sh->task) | 608 | if (NULL != sh->task) |
623 | { | 609 | { |
624 | GNUNET_SCHEDULER_cancel (sh->task); | 610 | GNUNET_SCHEDULER_cancel (sh->task); |