diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
commit | 75a33a1499cf60ea4364c9aa673816629a6c1413 (patch) | |
tree | 0620da4312bb04de4d7b65074fdd3b0c3dd6cc0e /src/peerinfo/peerinfo_api.c | |
parent | 7217c601ad30760872823193d62307e7a335d226 (diff) | |
download | gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.tar.gz gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.zip |
big scheduler refactoring, expect some issues
Diffstat (limited to 'src/peerinfo/peerinfo_api.c')
-rw-r--r-- | src/peerinfo/peerinfo_api.c | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c index 5803b076a..e7f095eac 100644 --- a/src/peerinfo/peerinfo_api.c +++ b/src/peerinfo/peerinfo_api.c | |||
@@ -91,11 +91,6 @@ struct GNUNET_PEERINFO_Handle | |||
91 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 91 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Our scheduler. | ||
95 | */ | ||
96 | struct GNUNET_SCHEDULER_Handle *sched; | ||
97 | |||
98 | /** | ||
99 | * Connection to the service. | 94 | * Connection to the service. |
100 | */ | 95 | */ |
101 | struct GNUNET_CLIENT_Connection *client; | 96 | struct GNUNET_CLIENT_Connection *client; |
@@ -127,25 +122,22 @@ struct GNUNET_PEERINFO_Handle | |||
127 | /** | 122 | /** |
128 | * Connect to the peerinfo service. | 123 | * Connect to the peerinfo service. |
129 | * | 124 | * |
130 | * @param sched scheduler to use | ||
131 | * @param cfg configuration to use | 125 | * @param cfg configuration to use |
132 | * @return NULL on error (configuration related, actual connection | 126 | * @return NULL on error (configuration related, actual connection |
133 | * establishment may happen asynchronously). | 127 | * establishment may happen asynchronously). |
134 | */ | 128 | */ |
135 | struct GNUNET_PEERINFO_Handle * | 129 | struct GNUNET_PEERINFO_Handle * |
136 | GNUNET_PEERINFO_connect (struct GNUNET_SCHEDULER_Handle *sched, | 130 | GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) |
137 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
138 | { | 131 | { |
139 | struct GNUNET_CLIENT_Connection *client; | 132 | struct GNUNET_CLIENT_Connection *client; |
140 | struct GNUNET_PEERINFO_Handle *ret; | 133 | struct GNUNET_PEERINFO_Handle *ret; |
141 | 134 | ||
142 | client = GNUNET_CLIENT_connect (sched, "peerinfo", cfg); | 135 | client = GNUNET_CLIENT_connect ("peerinfo", cfg); |
143 | if (client == NULL) | 136 | if (client == NULL) |
144 | return NULL; | 137 | return NULL; |
145 | ret = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_Handle)); | 138 | ret = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_Handle)); |
146 | ret->client = client; | 139 | ret->client = client; |
147 | ret->cfg = cfg; | 140 | ret->cfg = cfg; |
148 | ret->sched = sched; | ||
149 | return ret; | 141 | return ret; |
150 | } | 142 | } |
151 | 143 | ||
@@ -203,7 +195,7 @@ reconnect (struct GNUNET_PEERINFO_Handle *h) | |||
203 | { | 195 | { |
204 | GNUNET_CLIENT_disconnect (h->client, GNUNET_SYSERR); | 196 | GNUNET_CLIENT_disconnect (h->client, GNUNET_SYSERR); |
205 | h->th = NULL; | 197 | h->th = NULL; |
206 | h->client = GNUNET_CLIENT_connect (h->sched, "peerinfo", h->cfg); | 198 | h->client = GNUNET_CLIENT_connect ("peerinfo", h->cfg); |
207 | GNUNET_assert (h->client != NULL); | 199 | GNUNET_assert (h->client != NULL); |
208 | } | 200 | } |
209 | 201 | ||
@@ -395,8 +387,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
395 | reconnect (ic->h); | 387 | reconnect (ic->h); |
396 | trigger_transmit (ic->h); | 388 | trigger_transmit (ic->h); |
397 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 389 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
398 | GNUNET_SCHEDULER_cancel (ic->h->sched, | 390 | GNUNET_SCHEDULER_cancel (ic->timeout_task); |
399 | ic->timeout_task); | ||
400 | if (ic->callback != NULL) | 391 | if (ic->callback != NULL) |
401 | ic->callback (ic->callback_cls, NULL, NULL); | 392 | ic->callback (ic->callback_cls, NULL, NULL); |
402 | GNUNET_free (ic); | 393 | GNUNET_free (ic); |
@@ -411,8 +402,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
411 | #endif | 402 | #endif |
412 | trigger_transmit (ic->h); | 403 | trigger_transmit (ic->h); |
413 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 404 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
414 | GNUNET_SCHEDULER_cancel (ic->h->sched, | 405 | GNUNET_SCHEDULER_cancel (ic->timeout_task); |
415 | ic->timeout_task); | ||
416 | if (ic->callback != NULL) | 406 | if (ic->callback != NULL) |
417 | ic->callback (ic->callback_cls, NULL, NULL); | 407 | ic->callback (ic->callback_cls, NULL, NULL); |
418 | GNUNET_free (ic); | 408 | GNUNET_free (ic); |
@@ -426,8 +416,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
426 | reconnect (ic->h); | 416 | reconnect (ic->h); |
427 | trigger_transmit (ic->h); | 417 | trigger_transmit (ic->h); |
428 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 418 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
429 | GNUNET_SCHEDULER_cancel (ic->h->sched, | 419 | GNUNET_SCHEDULER_cancel (ic->timeout_task); |
430 | ic->timeout_task); | ||
431 | if (ic->callback != NULL) | 420 | if (ic->callback != NULL) |
432 | ic->callback (ic->callback_cls, NULL, NULL); | 421 | ic->callback (ic->callback_cls, NULL, NULL); |
433 | GNUNET_free (ic); | 422 | GNUNET_free (ic); |
@@ -445,8 +434,7 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
445 | reconnect (ic->h); | 434 | reconnect (ic->h); |
446 | trigger_transmit (ic->h); | 435 | trigger_transmit (ic->h); |
447 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 436 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
448 | GNUNET_SCHEDULER_cancel (ic->h->sched, | 437 | GNUNET_SCHEDULER_cancel (ic->timeout_task); |
449 | ic->timeout_task); | ||
450 | if (ic->callback != NULL) | 438 | if (ic->callback != NULL) |
451 | ic->callback (ic->callback_cls, NULL, NULL); | 439 | ic->callback (ic->callback_cls, NULL, NULL); |
452 | GNUNET_free (ic); | 440 | GNUNET_free (ic); |
@@ -492,8 +480,7 @@ iterator_start_receive (void *cls, | |||
492 | transmit_success); | 480 | transmit_success); |
493 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 481 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
494 | { | 482 | { |
495 | GNUNET_SCHEDULER_cancel (ic->h->sched, | 483 | GNUNET_SCHEDULER_cancel (ic->timeout_task); |
496 | ic->timeout_task); | ||
497 | ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 484 | ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
498 | } | 485 | } |
499 | reconnect (ic->h); | 486 | reconnect (ic->h); |
@@ -609,8 +596,7 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, | |||
609 | ic->callback = callback; | 596 | ic->callback = callback; |
610 | ic->callback_cls = callback_cls; | 597 | ic->callback_cls = callback_cls; |
611 | ic->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 598 | ic->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
612 | ic->timeout_task = GNUNET_SCHEDULER_add_delayed (h->sched, | 599 | ic->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, |
613 | timeout, | ||
614 | &signal_timeout, | 600 | &signal_timeout, |
615 | ic); | 601 | ic); |
616 | tqe->timeout = ic->timeout; | 602 | tqe->timeout = ic->timeout; |
@@ -637,8 +623,7 @@ GNUNET_PEERINFO_iterate_cancel (struct GNUNET_PEERINFO_IteratorContext *ic) | |||
637 | { | 623 | { |
638 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 624 | if (ic->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
639 | { | 625 | { |
640 | GNUNET_SCHEDULER_cancel (ic->h->sched, | 626 | GNUNET_SCHEDULER_cancel (ic->timeout_task); |
641 | ic->timeout_task); | ||
642 | ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 627 | ic->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
643 | } | 628 | } |
644 | ic->callback = NULL; | 629 | ic->callback = NULL; |