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/transport/transport_api.c | |
parent | 7217c601ad30760872823193d62307e7a335d226 (diff) | |
download | gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.tar.gz gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.zip |
big scheduler refactoring, expect some issues
Diffstat (limited to 'src/transport/transport_api.c')
-rw-r--r-- | src/transport/transport_api.c | 52 |
1 files changed, 18 insertions, 34 deletions
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index c0f32f93d..6fb35b5d6 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -327,11 +327,6 @@ struct GNUNET_TRANSPORT_Handle | |||
327 | struct HelloWaitList *hwl_head; | 327 | struct HelloWaitList *hwl_head; |
328 | 328 | ||
329 | /** | 329 | /** |
330 | * My scheduler. | ||
331 | */ | ||
332 | struct GNUNET_SCHEDULER_Handle *sched; | ||
333 | |||
334 | /** | ||
335 | * My configuration. | 330 | * My configuration. |
336 | */ | 331 | */ |
337 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 332 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
@@ -444,8 +439,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h) | |||
444 | 439 | ||
445 | if (h->quota_task != GNUNET_SCHEDULER_NO_TASK) | 440 | if (h->quota_task != GNUNET_SCHEDULER_NO_TASK) |
446 | { | 441 | { |
447 | GNUNET_SCHEDULER_cancel (h->sched, | 442 | GNUNET_SCHEDULER_cancel (h->quota_task); |
448 | h->quota_task); | ||
449 | h->quota_task = GNUNET_SCHEDULER_NO_TASK; | 443 | h->quota_task = GNUNET_SCHEDULER_NO_TASK; |
450 | } | 444 | } |
451 | retry_time = GNUNET_TIME_UNIT_FOREVER_REL; | 445 | retry_time = GNUNET_TIME_UNIT_FOREVER_REL; |
@@ -476,7 +470,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h) | |||
476 | #endif | 470 | #endif |
477 | if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) | 471 | if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) |
478 | { | 472 | { |
479 | GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); | 473 | GNUNET_SCHEDULER_cancel (th->notify_delay_task); |
480 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 474 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
481 | } | 475 | } |
482 | n->transmit_stage = TS_NEW; | 476 | n->transmit_stage = TS_NEW; |
@@ -510,8 +504,7 @@ schedule_peer_transmission (struct GNUNET_TRANSPORT_Handle *h) | |||
510 | ret = th; | 504 | ret = th; |
511 | } | 505 | } |
512 | if (ret == NULL) | 506 | if (ret == NULL) |
513 | h->quota_task = GNUNET_SCHEDULER_add_delayed (h->sched, | 507 | h->quota_task = GNUNET_SCHEDULER_add_delayed (retry_time, |
514 | retry_time, | ||
515 | "a_transmit_ready, | 508 | "a_transmit_ready, |
516 | h); | 509 | h); |
517 | return ret; | 510 | return ret; |
@@ -556,7 +549,7 @@ transport_notify_ready (void *cls, size_t size, void *buf) | |||
556 | { | 549 | { |
557 | if (cm->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) | 550 | if (cm->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) |
558 | { | 551 | { |
559 | GNUNET_SCHEDULER_cancel (h->sched, cm->notify_delay_task); | 552 | GNUNET_SCHEDULER_cancel (cm->notify_delay_task); |
560 | cm->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 553 | cm->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
561 | } | 554 | } |
562 | GNUNET_CONTAINER_DLL_remove (h->control_head, | 555 | GNUNET_CONTAINER_DLL_remove (h->control_head, |
@@ -578,7 +571,7 @@ transport_notify_ready (void *cls, size_t size, void *buf) | |||
578 | { | 571 | { |
579 | if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) | 572 | if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) |
580 | { | 573 | { |
581 | GNUNET_SCHEDULER_cancel (h->sched, th->notify_delay_task); | 574 | GNUNET_SCHEDULER_cancel (th->notify_delay_task); |
582 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 575 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
583 | } | 576 | } |
584 | n = th->neighbour; | 577 | n = th->neighbour; |
@@ -763,8 +756,7 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, | |||
763 | th->notify_cls = notify_cls; | 756 | th->notify_cls = notify_cls; |
764 | th->notify_size = size; | 757 | th->notify_size = size; |
765 | th->notify_delay_task | 758 | th->notify_delay_task |
766 | = GNUNET_SCHEDULER_add_delayed (h->sched, | 759 | = GNUNET_SCHEDULER_add_delayed (timeout, &control_transmit_timeout, th); |
767 | timeout, &control_transmit_timeout, th); | ||
768 | if (at_head) | 760 | if (at_head) |
769 | GNUNET_CONTAINER_DLL_insert (h->control_head, | 761 | GNUNET_CONTAINER_DLL_insert (h->control_head, |
770 | h->control_tail, | 762 | h->control_tail, |
@@ -810,8 +802,7 @@ send_set_quota (void *cls, size_t size, void *buf) | |||
810 | 802 | ||
811 | if (buf == NULL) | 803 | if (buf == NULL) |
812 | { | 804 | { |
813 | GNUNET_SCHEDULER_add_continuation (sqc->handle->sched, | 805 | GNUNET_SCHEDULER_add_continuation (sqc->cont, |
814 | sqc->cont, | ||
815 | sqc->cont_cls, | 806 | sqc->cont_cls, |
816 | GNUNET_SCHEDULER_REASON_TIMEOUT); | 807 | GNUNET_SCHEDULER_REASON_TIMEOUT); |
817 | GNUNET_free (sqc); | 808 | GNUNET_free (sqc); |
@@ -830,8 +821,7 @@ send_set_quota (void *cls, size_t size, void *buf) | |||
830 | msg->quota = sqc->quota_in; | 821 | msg->quota = sqc->quota_in; |
831 | memcpy (&msg->peer, &sqc->target, sizeof (struct GNUNET_PeerIdentity)); | 822 | memcpy (&msg->peer, &sqc->target, sizeof (struct GNUNET_PeerIdentity)); |
832 | if (sqc->cont != NULL) | 823 | if (sqc->cont != NULL) |
833 | GNUNET_SCHEDULER_add_continuation (sqc->handle->sched, | 824 | GNUNET_SCHEDULER_add_continuation (sqc->cont, |
834 | sqc->cont, | ||
835 | sqc->cont_cls, | 825 | sqc->cont_cls, |
836 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 826 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
837 | GNUNET_free (sqc); | 827 | GNUNET_free (sqc); |
@@ -1192,7 +1182,7 @@ reconnect (void *cls, | |||
1192 | "Connecting to transport service.\n"); | 1182 | "Connecting to transport service.\n"); |
1193 | #endif | 1183 | #endif |
1194 | GNUNET_assert (h->client == NULL); | 1184 | GNUNET_assert (h->client == NULL); |
1195 | h->client = GNUNET_CLIENT_connect (h->sched, "transport", h->cfg); | 1185 | h->client = GNUNET_CLIENT_connect ("transport", h->cfg); |
1196 | GNUNET_assert (h->client != NULL); | 1186 | GNUNET_assert (h->client != NULL); |
1197 | /* make sure we don't send "START" twice, remove existing entry from | 1187 | /* make sure we don't send "START" twice, remove existing entry from |
1198 | queue (if present) */ | 1188 | queue (if present) */ |
@@ -1206,7 +1196,7 @@ reconnect (void *cls, | |||
1206 | pos); | 1196 | pos); |
1207 | if (GNUNET_SCHEDULER_NO_TASK != pos->notify_delay_task) | 1197 | if (GNUNET_SCHEDULER_NO_TASK != pos->notify_delay_task) |
1208 | { | 1198 | { |
1209 | GNUNET_SCHEDULER_cancel (h->sched, pos->notify_delay_task); | 1199 | GNUNET_SCHEDULER_cancel (pos->notify_delay_task); |
1210 | pos->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 1200 | pos->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
1211 | } | 1201 | } |
1212 | GNUNET_free (pos); | 1202 | GNUNET_free (pos); |
@@ -1240,8 +1230,7 @@ schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h) | |||
1240 | GNUNET_assert (h->client == NULL); | 1230 | GNUNET_assert (h->client == NULL); |
1241 | GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); | 1231 | GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); |
1242 | h->reconnect_task | 1232 | h->reconnect_task |
1243 | = GNUNET_SCHEDULER_add_delayed (h->sched, | 1233 | = GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); |
1244 | h->reconnect_delay, &reconnect, h); | ||
1245 | if (h->reconnect_delay.rel_value == 0) | 1234 | if (h->reconnect_delay.rel_value == 0) |
1246 | { | 1235 | { |
1247 | h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS; | 1236 | h->reconnect_delay = GNUNET_TIME_UNIT_MILLISECONDS; |
@@ -1353,7 +1342,6 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, | |||
1353 | * Connect to the transport service. Note that the connection may | 1342 | * Connect to the transport service. Note that the connection may |
1354 | * complete (or fail) asynchronously. | 1343 | * complete (or fail) asynchronously. |
1355 | * | 1344 | * |
1356 | * @param sched scheduler to use | ||
1357 | * @param cfg configuration to use | 1345 | * @param cfg configuration to use |
1358 | * @param self our own identity (API should check that it matches | 1346 | * @param self our own identity (API should check that it matches |
1359 | * the identity found by transport), or NULL (no check) | 1347 | * the identity found by transport), or NULL (no check) |
@@ -1363,8 +1351,7 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h, | |||
1363 | * @param nd function to call on disconnect events | 1351 | * @param nd function to call on disconnect events |
1364 | */ | 1352 | */ |
1365 | struct GNUNET_TRANSPORT_Handle * | 1353 | struct GNUNET_TRANSPORT_Handle * |
1366 | GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched, | 1354 | GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
1367 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
1368 | const struct GNUNET_PeerIdentity *self, | 1355 | const struct GNUNET_PeerIdentity *self, |
1369 | void *cls, | 1356 | void *cls, |
1370 | GNUNET_TRANSPORT_ReceiveCallback rec, | 1357 | GNUNET_TRANSPORT_ReceiveCallback rec, |
@@ -1379,7 +1366,6 @@ GNUNET_TRANSPORT_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
1379 | ret->self = *self; | 1366 | ret->self = *self; |
1380 | ret->check_self = GNUNET_YES; | 1367 | ret->check_self = GNUNET_YES; |
1381 | } | 1368 | } |
1382 | ret->sched = sched; | ||
1383 | ret->cfg = cfg; | 1369 | ret->cfg = cfg; |
1384 | ret->cls = cls; | 1370 | ret->cls = cls; |
1385 | ret->rec = rec; | 1371 | ret->rec = rec; |
@@ -1421,8 +1407,7 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) | |||
1421 | th = &n->transmit_handle; | 1407 | th = &n->transmit_handle; |
1422 | if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) | 1408 | if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) |
1423 | { | 1409 | { |
1424 | GNUNET_SCHEDULER_cancel (handle->sched, | 1410 | GNUNET_SCHEDULER_cancel (th->notify_delay_task); |
1425 | th->notify_delay_task); | ||
1426 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 1411 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
1427 | } | 1412 | } |
1428 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); | 1413 | GNUNET_assert (0 == th->notify (th->notify_cls, 0, NULL)); |
@@ -1454,7 +1439,7 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) | |||
1454 | #endif | 1439 | #endif |
1455 | if (cm->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) | 1440 | if (cm->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) |
1456 | { | 1441 | { |
1457 | GNUNET_SCHEDULER_cancel (handle->sched, cm->notify_delay_task); | 1442 | GNUNET_SCHEDULER_cancel (cm->notify_delay_task); |
1458 | cm->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 1443 | cm->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
1459 | } | 1444 | } |
1460 | GNUNET_CONTAINER_DLL_remove (handle->control_head, | 1445 | GNUNET_CONTAINER_DLL_remove (handle->control_head, |
@@ -1466,12 +1451,12 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle) | |||
1466 | 1451 | ||
1467 | if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK) | 1452 | if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK) |
1468 | { | 1453 | { |
1469 | GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task); | 1454 | GNUNET_SCHEDULER_cancel (handle->reconnect_task); |
1470 | handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | 1455 | handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK; |
1471 | } | 1456 | } |
1472 | if (handle->quota_task != GNUNET_SCHEDULER_NO_TASK) | 1457 | if (handle->quota_task != GNUNET_SCHEDULER_NO_TASK) |
1473 | { | 1458 | { |
1474 | GNUNET_SCHEDULER_cancel (handle->sched, handle->quota_task); | 1459 | GNUNET_SCHEDULER_cancel (handle->quota_task); |
1475 | handle->quota_task = GNUNET_SCHEDULER_NO_TASK; | 1460 | handle->quota_task = GNUNET_SCHEDULER_NO_TASK; |
1476 | } | 1461 | } |
1477 | GNUNET_free_non_null (handle->my_hello); | 1462 | GNUNET_free_non_null (handle->my_hello); |
@@ -1857,7 +1842,7 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle | |||
1857 | th->notify_size = size + sizeof (struct OutboundMessage); | 1842 | th->notify_size = size + sizeof (struct OutboundMessage); |
1858 | th->priority = priority; | 1843 | th->priority = priority; |
1859 | th->notify_delay_task | 1844 | th->notify_delay_task |
1860 | = GNUNET_SCHEDULER_add_delayed (handle->sched, timeout, | 1845 | = GNUNET_SCHEDULER_add_delayed (timeout, |
1861 | &peer_transmit_timeout, th); | 1846 | &peer_transmit_timeout, th); |
1862 | schedule_transmission (handle); | 1847 | schedule_transmission (handle); |
1863 | return th; | 1848 | return th; |
@@ -1902,8 +1887,7 @@ GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct | |||
1902 | } | 1887 | } |
1903 | if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) | 1888 | if (th->notify_delay_task != GNUNET_SCHEDULER_NO_TASK) |
1904 | { | 1889 | { |
1905 | GNUNET_SCHEDULER_cancel (n->h->sched, | 1890 | GNUNET_SCHEDULER_cancel (th->notify_delay_task); |
1906 | th->notify_delay_task); | ||
1907 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; | 1891 | th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK; |
1908 | } | 1892 | } |
1909 | } | 1893 | } |