aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-11-05 18:21:50 +0000
committerNathan S. Evans <evans@in.tum.de>2010-11-05 18:21:50 +0000
commit75a33a1499cf60ea4364c9aa673816629a6c1413 (patch)
tree0620da4312bb04de4d7b65074fdd3b0c3dd6cc0e /src/core
parent7217c601ad30760872823193d62307e7a335d226 (diff)
downloadgnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.tar.gz
gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.zip
big scheduler refactoring, expect some issues
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core_api.c30
-rw-r--r--src/core/core_api_iterate_peers.c6
-rw-r--r--src/core/core_api_peer_get_info.c6
-rw-r--r--src/core/core_api_peer_request.c17
-rw-r--r--src/core/gnunet-service-core.c94
-rw-r--r--src/core/test_core_api.c18
-rw-r--r--src/core/test_core_api_reliability.c32
-rw-r--r--src/core/test_core_api_start_only.c9
-rw-r--r--src/core/test_core_quota_compliance.c37
9 files changed, 87 insertions, 162 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c
index dd8919ea1..cb5ba3ecb 100644
--- a/src/core/core_api.c
+++ b/src/core/core_api.c
@@ -36,10 +36,6 @@
36struct GNUNET_CORE_Handle 36struct GNUNET_CORE_Handle
37{ 37{
38 38
39 /**
40 * Our scheduler.
41 */
42 struct GNUNET_SCHEDULER_Handle *sched;
43 39
44 /** 40 /**
45 * Configuration we're using. 41 * Configuration we're using.
@@ -263,10 +259,9 @@ reconnect (struct GNUNET_CORE_Handle *h)
263 if (h->client_notifications != NULL) 259 if (h->client_notifications != NULL)
264 GNUNET_CLIENT_disconnect (h->client_notifications, GNUNET_NO); 260 GNUNET_CLIENT_disconnect (h->client_notifications, GNUNET_NO);
265 h->currently_down = GNUNET_YES; 261 h->currently_down = GNUNET_YES;
266 h->client_notifications = GNUNET_CLIENT_connect (h->sched, "core", h->cfg); 262 h->client_notifications = GNUNET_CLIENT_connect ("core", h->cfg);
267 if (h->client_notifications == NULL) 263 if (h->client_notifications == NULL)
268 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->sched, 264 h->reconnect_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
269 GNUNET_TIME_UNIT_SECONDS,
270 &reconnect_task, 265 &reconnect_task,
271 h); 266 h);
272 else 267 else
@@ -328,7 +323,7 @@ request_start (void *cls, size_t size, void *buf)
328 { 323 {
329 if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK) 324 if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK)
330 { 325 {
331 GNUNET_SCHEDULER_cancel(h->sched, th->timeout_task); 326 GNUNET_SCHEDULER_cancel(th->timeout_task);
332 th->timeout_task = GNUNET_SCHEDULER_NO_TASK; 327 th->timeout_task = GNUNET_SCHEDULER_NO_TASK;
333 } 328 }
334 timeout_request (th, NULL); 329 timeout_request (th, NULL);
@@ -673,8 +668,7 @@ transmit_start (void *cls, size_t size, void *buf)
673 h->startup_timeout = 668 h->startup_timeout =
674 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES); 669 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES);
675 h->reconnect_task = 670 h->reconnect_task =
676 GNUNET_SCHEDULER_add_delayed (h->sched, 671 GNUNET_SCHEDULER_add_delayed (delay, &reconnect_task, h);
677 delay, &reconnect_task, h);
678 return 0; 672 return 0;
679 } 673 }
680 /* timeout on initial connect */ 674 /* timeout on initial connect */
@@ -727,7 +721,6 @@ transmit_start (void *cls, size_t size, void *buf)
727 * Connect to the core service. Note that the connection may 721 * Connect to the core service. Note that the connection may
728 * complete (or fail) asynchronously. 722 * complete (or fail) asynchronously.
729 * 723 *
730 * @param sched scheduler to use
731 * @param cfg configuration to use 724 * @param cfg configuration to use
732 * @param timeout after how long should we give up trying to connect to the core service? 725 * @param timeout after how long should we give up trying to connect to the core service?
733 * @param cls closure for the various callbacks that follow (including handlers in the handlers array) 726 * @param cls closure for the various callbacks that follow (including handlers in the handlers array)
@@ -749,8 +742,7 @@ transmit_start (void *cls, size_t size, void *buf)
749 * NULL on error (in this case, init is never called) 742 * NULL on error (in this case, init is never called)
750 */ 743 */
751struct GNUNET_CORE_Handle * 744struct GNUNET_CORE_Handle *
752GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, 745GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
753 const struct GNUNET_CONFIGURATION_Handle *cfg,
754 struct GNUNET_TIME_Relative timeout, 746 struct GNUNET_TIME_Relative timeout,
755 void *cls, 747 void *cls,
756 GNUNET_CORE_StartupCallback init, 748 GNUNET_CORE_StartupCallback init,
@@ -766,7 +758,6 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched,
766 struct GNUNET_CORE_Handle *h; 758 struct GNUNET_CORE_Handle *h;
767 759
768 h = GNUNET_malloc (sizeof (struct GNUNET_CORE_Handle)); 760 h = GNUNET_malloc (sizeof (struct GNUNET_CORE_Handle));
769 h->sched = sched;
770 h->cfg = cfg; 761 h->cfg = cfg;
771 h->cls = cls; 762 h->cls = cls;
772 h->init = init; 763 h->init = init;
@@ -778,7 +769,7 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched,
778 h->inbound_hdr_only = inbound_hdr_only; 769 h->inbound_hdr_only = inbound_hdr_only;
779 h->outbound_hdr_only = outbound_hdr_only; 770 h->outbound_hdr_only = outbound_hdr_only;
780 h->handlers = handlers; 771 h->handlers = handlers;
781 h->client_notifications = GNUNET_CLIENT_connect (sched, "core", cfg); 772 h->client_notifications = GNUNET_CLIENT_connect ("core", cfg);
782 if (h->client_notifications == NULL) 773 if (h->client_notifications == NULL)
783 { 774 {
784 GNUNET_free (h); 775 GNUNET_free (h);
@@ -819,7 +810,7 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle)
819 if (handle->solicit_transmit_req != NULL) 810 if (handle->solicit_transmit_req != NULL)
820 GNUNET_CORE_notify_transmit_ready_cancel (handle->solicit_transmit_req); 811 GNUNET_CORE_notify_transmit_ready_cancel (handle->solicit_transmit_req);
821 if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK) 812 if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
822 GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task); 813 GNUNET_SCHEDULER_cancel (handle->reconnect_task);
823 if (handle->client_notifications != NULL) 814 if (handle->client_notifications != NULL)
824 GNUNET_CLIENT_disconnect (handle->client_notifications, GNUNET_NO); 815 GNUNET_CLIENT_disconnect (handle->client_notifications, GNUNET_NO);
825 GNUNET_break (handle->pending_head == NULL); 816 GNUNET_break (handle->pending_head == NULL);
@@ -950,8 +941,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle,
950 th->notify_cls = notify_cls; 941 th->notify_cls = notify_cls;
951 th->peer = *target; 942 th->peer = *target;
952 th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay); 943 th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay);
953 th->timeout_task = GNUNET_SCHEDULER_add_delayed (handle->sched, 944 th->timeout_task = GNUNET_SCHEDULER_add_delayed (maxdelay,
954 maxdelay,
955 &timeout_request, th); 945 &timeout_request, th);
956 th->priority = priority; 946 th->priority = priority;
957 th->msize = sizeof (struct SendMessage) + notify_size; 947 th->msize = sizeof (struct SendMessage) + notify_size;
@@ -965,7 +955,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle,
965 955
966/** 956/**
967 * Cancel the specified transmission-ready notification. 957 * Cancel the specified transmission-ready notification.
968 * 958 *s
969 * @param th handle that was returned by "notify_transmit_ready". 959 * @param th handle that was returned by "notify_transmit_ready".
970 */ 960 */
971void 961void
@@ -981,7 +971,7 @@ GNUNET_CORE_notify_transmit_ready_cancel (struct GNUNET_CORE_TransmitHandle
981 h->pending_tail, 971 h->pending_tail,
982 th); 972 th);
983 if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK) 973 if (th->timeout_task != GNUNET_SCHEDULER_NO_TASK)
984 GNUNET_SCHEDULER_cancel (h->sched, th->timeout_task); 974 GNUNET_SCHEDULER_cancel (th->timeout_task);
985 GNUNET_free (th); 975 GNUNET_free (th);
986} 976}
987 977
diff --git a/src/core/core_api_iterate_peers.c b/src/core/core_api_iterate_peers.c
index 08cb9797c..aeef67f88 100644
--- a/src/core/core_api_iterate_peers.c
+++ b/src/core/core_api_iterate_peers.c
@@ -134,22 +134,20 @@ transmit_request(void *cls,
134/** 134/**
135 * Obtain statistics and/or change preferences for the given peer. 135 * Obtain statistics and/or change preferences for the given peer.
136 * 136 *
137 * @param sched scheduler to use
138 * @param cfg configuration to use 137 * @param cfg configuration to use
139 * @param peer_cb function to call with the peer information 138 * @param peer_cb function to call with the peer information
140 * @param cb_cls closure for peer_cb 139 * @param cb_cls closure for peer_cb
141 * @return GNUNET_OK if iterating, GNUNET_SYSERR on error 140 * @return GNUNET_OK if iterating, GNUNET_SYSERR on error
142 */ 141 */
143int 142int
144GNUNET_CORE_iterate_peers (struct GNUNET_SCHEDULER_Handle *sched, 143GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
145 const struct GNUNET_CONFIGURATION_Handle *cfg,
146 GNUNET_CORE_ConnectEventHandler peer_cb, 144 GNUNET_CORE_ConnectEventHandler peer_cb,
147 void *cb_cls) 145 void *cb_cls)
148{ 146{
149 struct GNUNET_CORE_RequestContext *request_context; 147 struct GNUNET_CORE_RequestContext *request_context;
150 struct GNUNET_CLIENT_Connection *client; 148 struct GNUNET_CLIENT_Connection *client;
151 149
152 client = GNUNET_CLIENT_connect (sched, "core", cfg); 150 client = GNUNET_CLIENT_connect ("core", cfg);
153 if (client == NULL) 151 if (client == NULL)
154 return GNUNET_SYSERR; 152 return GNUNET_SYSERR;
155 request_context = GNUNET_malloc (sizeof (struct GNUNET_CORE_RequestContext)); 153 request_context = GNUNET_malloc (sizeof (struct GNUNET_CORE_RequestContext));
diff --git a/src/core/core_api_peer_get_info.c b/src/core/core_api_peer_get_info.c
index 68cf2da11..1ca8d82af 100644
--- a/src/core/core_api_peer_get_info.c
+++ b/src/core/core_api_peer_get_info.c
@@ -99,7 +99,6 @@ receive_info (void *cls,
99/** 99/**
100 * Obtain statistics and/or change preferences for the given peer. 100 * Obtain statistics and/or change preferences for the given peer.
101 * 101 *
102 * @param sched scheduler to use
103 * @param cfg configuration to use 102 * @param cfg configuration to use
104 * @param peer identifies the peer 103 * @param peer identifies the peer
105 * @param timeout after how long should we give up (and call "info" with NULL 104 * @param timeout after how long should we give up (and call "info" with NULL
@@ -122,8 +121,7 @@ receive_info (void *cls,
122 * @return NULL on error 121 * @return NULL on error
123 */ 122 */
124struct GNUNET_CORE_InformationRequestContext * 123struct GNUNET_CORE_InformationRequestContext *
125GNUNET_CORE_peer_change_preference (struct GNUNET_SCHEDULER_Handle *sched, 124GNUNET_CORE_peer_change_preference (const struct GNUNET_CONFIGURATION_Handle *cfg,
126 const struct GNUNET_CONFIGURATION_Handle *cfg,
127 const struct GNUNET_PeerIdentity *peer, 125 const struct GNUNET_PeerIdentity *peer,
128 struct GNUNET_TIME_Relative timeout, 126 struct GNUNET_TIME_Relative timeout,
129 struct GNUNET_BANDWIDTH_Value32NBO bw_out, 127 struct GNUNET_BANDWIDTH_Value32NBO bw_out,
@@ -137,7 +135,7 @@ GNUNET_CORE_peer_change_preference (struct GNUNET_SCHEDULER_Handle *sched,
137 struct GNUNET_CLIENT_Connection *client; 135 struct GNUNET_CLIENT_Connection *client;
138 int retry; 136 int retry;
139 137
140 client = GNUNET_CLIENT_connect (sched, "core", cfg); 138 client = GNUNET_CLIENT_connect ("core", cfg);
141 if (client == NULL) 139 if (client == NULL)
142 return NULL; 140 return NULL;
143 irc = GNUNET_malloc (sizeof (struct GNUNET_CORE_InformationRequestContext)); 141 irc = GNUNET_malloc (sizeof (struct GNUNET_CORE_InformationRequestContext));
diff --git a/src/core/core_api_peer_request.c b/src/core/core_api_peer_request.c
index 96640990a..0f13f15f9 100644
--- a/src/core/core_api_peer_request.c
+++ b/src/core/core_api_peer_request.c
@@ -41,10 +41,6 @@ struct GNUNET_CORE_PeerRequestHandle
41 */ 41 */
42 struct GNUNET_CLIENT_Connection *client; 42 struct GNUNET_CLIENT_Connection *client;
43 43
44 /**
45 * Scheduler.
46 */
47 struct GNUNET_SCHEDULER_Handle *sched;
48 44
49 /** 45 /**
50 * Function to call once done. 46 * Function to call once done.
@@ -92,8 +88,7 @@ send_request (void *cls,
92 if (buf == NULL) 88 if (buf == NULL)
93 { 89 {
94 if (prh->cont != NULL) 90 if (prh->cont != NULL)
95 GNUNET_SCHEDULER_add_continuation (prh->sched, 91 GNUNET_SCHEDULER_add_continuation (prh->cont,
96 prh->cont,
97 prh->cont_cls, 92 prh->cont_cls,
98 GNUNET_SCHEDULER_REASON_TIMEOUT); 93 GNUNET_SCHEDULER_REASON_TIMEOUT);
99 GNUNET_CLIENT_disconnect (prh->client, GNUNET_NO); 94 GNUNET_CLIENT_disconnect (prh->client, GNUNET_NO);
@@ -109,8 +104,7 @@ send_request (void *cls,
109 memcpy (buf, &msg, sizeof (msg)); 104 memcpy (buf, &msg, sizeof (msg));
110 if (prh->cont != NULL) 105 if (prh->cont != NULL)
111 { 106 {
112 GNUNET_SCHEDULER_add_continuation (prh->sched, 107 GNUNET_SCHEDULER_add_continuation (prh->cont,
113 prh->cont,
114 prh->cont_cls, 108 prh->cont_cls,
115 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 109 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
116 } 110 }
@@ -131,7 +125,6 @@ send_request (void *cls,
131 * to our connection attempt within the given time frame, 'cont' will 125 * to our connection attempt within the given time frame, 'cont' will
132 * be called with the TIMEOUT reason code. 126 * be called with the TIMEOUT reason code.
133 * 127 *
134 * @param sched scheduler to use
135 * @param cfg configuration to use 128 * @param cfg configuration to use
136 * @param timeout how long to try to talk to core 129 * @param timeout how long to try to talk to core
137 * @param peer who should we connect to 130 * @param peer who should we connect to
@@ -140,8 +133,7 @@ send_request (void *cls,
140 * @return NULL on error (cont will not be called), otherwise handle for cancellation 133 * @return NULL on error (cont will not be called), otherwise handle for cancellation
141 */ 134 */
142struct GNUNET_CORE_PeerRequestHandle * 135struct GNUNET_CORE_PeerRequestHandle *
143GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched, 136GNUNET_CORE_peer_request_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
144 const struct GNUNET_CONFIGURATION_Handle *cfg,
145 struct GNUNET_TIME_Relative timeout, 137 struct GNUNET_TIME_Relative timeout,
146 const struct GNUNET_PeerIdentity * peer, 138 const struct GNUNET_PeerIdentity * peer,
147 GNUNET_SCHEDULER_Task cont, 139 GNUNET_SCHEDULER_Task cont,
@@ -150,12 +142,11 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched,
150 struct GNUNET_CORE_PeerRequestHandle *ret; 142 struct GNUNET_CORE_PeerRequestHandle *ret;
151 struct GNUNET_CLIENT_Connection *client; 143 struct GNUNET_CLIENT_Connection *client;
152 144
153 client = GNUNET_CLIENT_connect (sched, "core", cfg); 145 client = GNUNET_CLIENT_connect ("core", cfg);
154 if (client == NULL) 146 if (client == NULL)
155 return NULL; 147 return NULL;
156 ret = GNUNET_malloc (sizeof (struct GNUNET_CORE_PeerRequestHandle)); 148 ret = GNUNET_malloc (sizeof (struct GNUNET_CORE_PeerRequestHandle));
157 ret->client = client; 149 ret->client = client;
158 ret->sched = sched;
159 ret->cont = cont; 150 ret->cont = cont;
160 ret->cont_cls = cont_cls; 151 ret->cont_cls = cont_cls;
161 ret->peer = *peer; 152 ret->peer = *peer;
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index 6b662982d..c1ebdb9df 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -657,10 +657,6 @@ static struct GNUNET_PeerIdentity my_identity;
657 */ 657 */
658static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; 658static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
659 659
660/**
661 * Our scheduler.
662 */
663struct GNUNET_SCHEDULER_Handle *sched;
664 660
665/** 661/**
666 * Handle to peerinfo service. 662 * Handle to peerinfo service.
@@ -1259,15 +1255,15 @@ free_neighbour (struct Neighbour *n)
1259 n->th = NULL; 1255 n->th = NULL;
1260 } 1256 }
1261 if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_TASK) 1257 if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_TASK)
1262 GNUNET_SCHEDULER_cancel (sched, n->retry_plaintext_task); 1258 GNUNET_SCHEDULER_cancel (n->retry_plaintext_task);
1263 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) 1259 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
1264 GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); 1260 GNUNET_SCHEDULER_cancel (n->retry_set_key_task);
1265 if (n->quota_update_task != GNUNET_SCHEDULER_NO_TASK) 1261 if (n->quota_update_task != GNUNET_SCHEDULER_NO_TASK)
1266 GNUNET_SCHEDULER_cancel (sched, n->quota_update_task); 1262 GNUNET_SCHEDULER_cancel (n->quota_update_task);
1267 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) 1263 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK)
1268 GNUNET_SCHEDULER_cancel (sched, n->dead_clean_task); 1264 GNUNET_SCHEDULER_cancel (n->dead_clean_task);
1269 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) 1265 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
1270 GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); 1266 GNUNET_SCHEDULER_cancel (n->keep_alive_task);
1271 if (n->status == PEER_STATE_KEY_CONFIRMED) 1267 if (n->status == PEER_STATE_KEY_CONFIRMED)
1272 GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"), -1, GNUNET_NO); 1268 GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"), -1, GNUNET_NO);
1273 GNUNET_free_non_null (n->public_key); 1269 GNUNET_free_non_null (n->public_key);
@@ -1397,8 +1393,7 @@ send_keep_alive (void *cls,
1397 retry = GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2), 1393 retry = GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2),
1398 MIN_PING_FREQUENCY); 1394 MIN_PING_FREQUENCY);
1399 n->keep_alive_task 1395 n->keep_alive_task
1400 = GNUNET_SCHEDULER_add_delayed (sched, 1396 = GNUNET_SCHEDULER_add_delayed (retry,
1401 retry,
1402 &send_keep_alive, 1397 &send_keep_alive,
1403 n); 1398 n);
1404 1399
@@ -1445,9 +1440,8 @@ consider_free_neighbour (struct Neighbour *n)
1445 if (left.rel_value > 0) 1440 if (left.rel_value > 0)
1446 { 1441 {
1447 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) 1442 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK)
1448 GNUNET_SCHEDULER_cancel (sched, n->dead_clean_task); 1443 GNUNET_SCHEDULER_cancel (n->dead_clean_task);
1449 n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (sched, 1444 n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (left,
1450 left,
1451 &consider_free_task, 1445 &consider_free_task,
1452 n); 1446 n);
1453 return; 1447 return;
@@ -2087,7 +2081,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
2087 2081
2088 if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_TASK) 2082 if (n->retry_plaintext_task != GNUNET_SCHEDULER_NO_TASK)
2089 { 2083 {
2090 GNUNET_SCHEDULER_cancel (sched, n->retry_plaintext_task); 2084 GNUNET_SCHEDULER_cancel (n->retry_plaintext_task);
2091 n->retry_plaintext_task = GNUNET_SCHEDULER_NO_TASK; 2085 n->retry_plaintext_task = GNUNET_SCHEDULER_NO_TASK;
2092 } 2086 }
2093 switch (n->status) 2087 switch (n->status)
@@ -2103,8 +2097,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
2103 case PEER_STATE_KEY_SENT: 2097 case PEER_STATE_KEY_SENT:
2104 if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK) 2098 if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK)
2105 n->retry_set_key_task 2099 n->retry_set_key_task
2106 = GNUNET_SCHEDULER_add_delayed (sched, 2100 = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
2107 n->set_key_retry_frequency,
2108 &set_key_retry_task, n); 2101 &set_key_retry_task, n);
2109#if DEBUG_CORE 2102#if DEBUG_CORE
2110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2115,8 +2108,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
2115 case PEER_STATE_KEY_RECEIVED: 2108 case PEER_STATE_KEY_RECEIVED:
2116 if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK) 2109 if (n->retry_set_key_task == GNUNET_SCHEDULER_NO_TASK)
2117 n->retry_set_key_task 2110 n->retry_set_key_task
2118 = GNUNET_SCHEDULER_add_delayed (sched, 2111 = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
2119 n->set_key_retry_frequency,
2120 &set_key_retry_task, n); 2112 &set_key_retry_task, n);
2121#if DEBUG_CORE 2113#if DEBUG_CORE
2122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2114 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2165,8 +2157,7 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
2165#endif 2157#endif
2166 /* no messages selected for sending, try again later... */ 2158 /* no messages selected for sending, try again later... */
2167 n->retry_plaintext_task = 2159 n->retry_plaintext_task =
2168 GNUNET_SCHEDULER_add_delayed (sched, 2160 GNUNET_SCHEDULER_add_delayed (retry_time,
2169 retry_time,
2170 &retry_plaintext_processing, n); 2161 &retry_plaintext_processing, n);
2171 return; 2162 return;
2172 } 2163 }
@@ -2252,8 +2243,7 @@ schedule_quota_update (struct Neighbour *n)
2252 GNUNET_assert (n->quota_update_task == 2243 GNUNET_assert (n->quota_update_task ==
2253 GNUNET_SCHEDULER_NO_TASK); 2244 GNUNET_SCHEDULER_NO_TASK);
2254 n->quota_update_task 2245 n->quota_update_task
2255 = GNUNET_SCHEDULER_add_delayed (sched, 2246 = GNUNET_SCHEDULER_add_delayed (QUOTA_UPDATE_FREQUENCY,
2256 QUOTA_UPDATE_FREQUENCY,
2257 &neighbour_quota_update, 2247 &neighbour_quota_update,
2258 n); 2248 n);
2259} 2249}
@@ -2475,10 +2465,8 @@ notify_transport_connect_done (void *cls, size_t size, void *buf)
2475 _("TRANSPORT connection to peer `%4s' is up, trying to establish CORE connection\n"), 2465 _("TRANSPORT connection to peer `%4s' is up, trying to establish CORE connection\n"),
2476 GNUNET_i2s (&n->peer)); 2466 GNUNET_i2s (&n->peer));
2477 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) 2467 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
2478 GNUNET_SCHEDULER_cancel (sched, 2468 GNUNET_SCHEDULER_cancel (n->retry_set_key_task);
2479 n->retry_set_key_task); 2469 n->retry_set_key_task = GNUNET_SCHEDULER_add_now (&set_key_retry_task,
2480 n->retry_set_key_task = GNUNET_SCHEDULER_add_now (sched,
2481 &set_key_retry_task,
2482 n); 2470 n);
2483 return 0; 2471 return 0;
2484} 2472}
@@ -2567,7 +2555,7 @@ process_hello_retry_send_key (void *cls,
2567 { 2555 {
2568 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) 2556 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
2569 { 2557 {
2570 GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); 2558 GNUNET_SCHEDULER_cancel (n->retry_set_key_task);
2571 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; 2559 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
2572 } 2560 }
2573 GNUNET_STATISTICS_update (stats, 2561 GNUNET_STATISTICS_update (stats,
@@ -2589,8 +2577,7 @@ process_hello_retry_send_key (void *cls,
2589 GNUNET_NO); 2577 GNUNET_NO);
2590 if (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task) 2578 if (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task)
2591 n->retry_set_key_task 2579 n->retry_set_key_task
2592 = GNUNET_SCHEDULER_add_delayed (sched, 2580 = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
2593 n->set_key_retry_frequency,
2594 &set_key_retry_task, n); 2581 &set_key_retry_task, n);
2595 } 2582 }
2596 return; 2583 return;
@@ -2651,7 +2638,7 @@ send_key (struct Neighbour *n)
2651 2638
2652 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) 2639 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
2653 { 2640 {
2654 GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); 2641 GNUNET_SCHEDULER_cancel (n->retry_set_key_task);
2655 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; 2642 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
2656 } 2643 }
2657 if (n->pitr != NULL) 2644 if (n->pitr != NULL)
@@ -2829,8 +2816,7 @@ send_key (struct Neighbour *n)
2829 if ( (n->status != PEER_STATE_KEY_CONFIRMED) && 2816 if ( (n->status != PEER_STATE_KEY_CONFIRMED) &&
2830 (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task) ) 2817 (GNUNET_SCHEDULER_NO_TASK == n->retry_set_key_task) )
2831 n->retry_set_key_task 2818 n->retry_set_key_task
2832 = GNUNET_SCHEDULER_add_delayed (sched, 2819 = GNUNET_SCHEDULER_add_delayed (n->set_key_retry_frequency,
2833 n->set_key_retry_frequency,
2834 &set_key_retry_task, n); 2820 &set_key_retry_task, n);
2835} 2821}
2836 2822
@@ -3096,7 +3082,7 @@ handle_pong (struct Neighbour *n,
3096#endif 3082#endif
3097 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK) 3083 if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
3098 { 3084 {
3099 GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); 3085 GNUNET_SCHEDULER_cancel (n->retry_set_key_task);
3100 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK; 3086 n->retry_set_key_task = GNUNET_SCHEDULER_NO_TASK;
3101 } 3087 }
3102 cnm.header.size = htons (sizeof (struct ConnectNotifyMessage)); 3088 cnm.header.size = htons (sizeof (struct ConnectNotifyMessage));
@@ -3110,10 +3096,9 @@ handle_pong (struct Neighbour *n,
3110 case PEER_STATE_KEY_CONFIRMED: 3096 case PEER_STATE_KEY_CONFIRMED:
3111 n->last_activity = GNUNET_TIME_absolute_get (); 3097 n->last_activity = GNUNET_TIME_absolute_get ();
3112 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) 3098 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
3113 GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); 3099 GNUNET_SCHEDULER_cancel (n->keep_alive_task);
3114 n->keep_alive_task 3100 n->keep_alive_task
3115 = GNUNET_SCHEDULER_add_delayed (sched, 3101 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3116 GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3117 &send_keep_alive, 3102 &send_keep_alive,
3118 n); 3103 n);
3119 handle_peer_status_change (n); 3104 handle_peer_status_change (n);
@@ -3560,10 +3545,9 @@ handle_encrypted_message (struct Neighbour *n,
3560 } 3545 }
3561 n->last_activity = GNUNET_TIME_absolute_get (); 3546 n->last_activity = GNUNET_TIME_absolute_get ();
3562 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) 3547 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
3563 GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); 3548 GNUNET_SCHEDULER_cancel (n->keep_alive_task);
3564 n->keep_alive_task 3549 n->keep_alive_task
3565 = GNUNET_SCHEDULER_add_delayed (sched, 3550 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3566 GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3567 &send_keep_alive, 3551 &send_keep_alive,
3568 n); 3552 n);
3569 GNUNET_STATISTICS_set (stats, 3553 GNUNET_STATISTICS_set (stats,
@@ -3711,10 +3695,9 @@ handle_transport_receive (void *cls,
3711 n->time_established = now; 3695 n->time_established = now;
3712 } 3696 }
3713 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK) 3697 if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
3714 GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task); 3698 GNUNET_SCHEDULER_cancel (n->keep_alive_task);
3715 n->keep_alive_task 3699 n->keep_alive_task
3716 = GNUNET_SCHEDULER_add_delayed (sched, 3700 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3717 GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3718 &send_keep_alive, 3701 &send_keep_alive,
3719 n); 3702 n);
3720 } 3703 }
@@ -3912,14 +3895,12 @@ handle_transport_notify_disconnect (void *cls,
3912 -1, 3895 -1,
3913 GNUNET_NO); 3896 GNUNET_NO);
3914 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK) 3897 if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK)
3915 GNUNET_SCHEDULER_cancel (sched, 3898 GNUNET_SCHEDULER_cancel (n->dead_clean_task);
3916 n->dead_clean_task);
3917 left = GNUNET_TIME_relative_subtract (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 3899 left = GNUNET_TIME_relative_subtract (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
3918 GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT); 3900 GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT);
3919 n->last_activity = GNUNET_TIME_absolute_subtract (GNUNET_TIME_absolute_get (), 3901 n->last_activity = GNUNET_TIME_absolute_subtract (GNUNET_TIME_absolute_get (),
3920 left); 3902 left);
3921 n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (sched, 3903 n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT,
3922 GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT,
3923 &consider_free_task, 3904 &consider_free_task,
3924 n); 3905 n);
3925} 3906}
@@ -3969,13 +3950,11 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3969 * Initiate core service. 3950 * Initiate core service.
3970 * 3951 *
3971 * @param cls closure 3952 * @param cls closure
3972 * @param s scheduler to use
3973 * @param server the initialized server 3953 * @param server the initialized server
3974 * @param c configuration to use 3954 * @param c configuration to use
3975 */ 3955 */
3976static void 3956static void
3977run (void *cls, 3957run (void *cls,
3978 struct GNUNET_SCHEDULER_Handle *s,
3979 struct GNUNET_SERVER_Handle *server, 3958 struct GNUNET_SERVER_Handle *server,
3980 const struct GNUNET_CONFIGURATION_Handle *c) 3959 const struct GNUNET_CONFIGURATION_Handle *c)
3981{ 3960{
@@ -3997,7 +3976,6 @@ run (void *cls,
3997 }; 3976 };
3998 char *keyfile; 3977 char *keyfile;
3999 3978
4000 sched = s;
4001 cfg = c; 3979 cfg = c;
4002 /* parse configuration */ 3980 /* parse configuration */
4003 if ( 3981 if (
@@ -4019,15 +3997,15 @@ run (void *cls,
4019 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3997 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
4020 _ 3998 _
4021 ("Core service is lacking key configuration settings. Exiting.\n")); 3999 ("Core service is lacking key configuration settings. Exiting.\n"));
4022 GNUNET_SCHEDULER_shutdown (s); 4000 GNUNET_SCHEDULER_shutdown ();
4023 return; 4001 return;
4024 } 4002 }
4025 peerinfo = GNUNET_PEERINFO_connect (sched, cfg); 4003 peerinfo = GNUNET_PEERINFO_connect (cfg);
4026 if (NULL == peerinfo) 4004 if (NULL == peerinfo)
4027 { 4005 {
4028 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 4006 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
4029 _("Could not access PEERINFO service. Exiting.\n")); 4007 _("Could not access PEERINFO service. Exiting.\n"));
4030 GNUNET_SCHEDULER_shutdown (s); 4008 GNUNET_SCHEDULER_shutdown ();
4031 GNUNET_free (keyfile); 4009 GNUNET_free (keyfile);
4032 return; 4010 return;
4033 } 4011 }
@@ -4038,7 +4016,7 @@ run (void *cls,
4038 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 4016 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
4039 _("Core service could not access hostkey. Exiting.\n")); 4017 _("Core service could not access hostkey. Exiting.\n"));
4040 GNUNET_PEERINFO_disconnect (peerinfo); 4018 GNUNET_PEERINFO_disconnect (peerinfo);
4041 GNUNET_SCHEDULER_shutdown (s); 4019 GNUNET_SCHEDULER_shutdown ();
4042 return; 4020 return;
4043 } 4021 }
4044 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); 4022 GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
@@ -4049,23 +4027,21 @@ run (void *cls,
4049 MAX_NOTIFY_QUEUE); 4027 MAX_NOTIFY_QUEUE);
4050 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); 4028 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
4051 /* setup transport connection */ 4029 /* setup transport connection */
4052 transport = GNUNET_TRANSPORT_connect (sched, 4030 transport = GNUNET_TRANSPORT_connect (cfg,
4053 cfg,
4054 &my_identity, 4031 &my_identity,
4055 NULL, 4032 NULL,
4056 &handle_transport_receive, 4033 &handle_transport_receive,
4057 &handle_transport_notify_connect, 4034 &handle_transport_notify_connect,
4058 &handle_transport_notify_disconnect); 4035 &handle_transport_notify_disconnect);
4059 GNUNET_assert (NULL != transport); 4036 GNUNET_assert (NULL != transport);
4060 stats = GNUNET_STATISTICS_create (sched, "core", cfg); 4037 stats = GNUNET_STATISTICS_create ("core", cfg);
4061 4038
4062 GNUNET_STATISTICS_set (stats, gettext_noop ("# discarded CORE_SEND requests"), 0, GNUNET_NO); 4039 GNUNET_STATISTICS_set (stats, gettext_noop ("# discarded CORE_SEND requests"), 0, GNUNET_NO);
4063 GNUNET_STATISTICS_set (stats, gettext_noop ("# discarded lower priority CORE_SEND requests"), 0, GNUNET_NO); 4040 GNUNET_STATISTICS_set (stats, gettext_noop ("# discarded lower priority CORE_SEND requests"), 0, GNUNET_NO);
4064 4041
4065 mst = GNUNET_SERVER_mst_create (&deliver_message, 4042 mst = GNUNET_SERVER_mst_create (&deliver_message,
4066 NULL); 4043 NULL);
4067 GNUNET_SCHEDULER_add_delayed (sched, 4044 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
4068 GNUNET_TIME_UNIT_FOREVER_REL,
4069 &cleaning_task, NULL); 4045 &cleaning_task, NULL);
4070 /* process client requests */ 4046 /* process client requests */
4071 GNUNET_SERVER_add_handlers (server, handlers); 4047 GNUNET_SERVER_add_handlers (server, handlers);
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c
index 3fbeca419..65b09c835 100644
--- a/src/core/test_core_api.c
+++ b/src/core/test_core_api.c
@@ -62,7 +62,6 @@ static struct PeerContext p1;
62 62
63static struct PeerContext p2; 63static struct PeerContext p2;
64 64
65static struct GNUNET_SCHEDULER_Handle *sched;
66 65
67static int ok; 66static int ok;
68 67
@@ -168,8 +167,8 @@ process_mtype (void *cls,
168 "Receiving message from `%4s'.\n", GNUNET_i2s (peer)); 167 "Receiving message from `%4s'.\n", GNUNET_i2s (peer));
169 GNUNET_assert (ok == 5); 168 GNUNET_assert (ok == 5);
170 OKPP; 169 OKPP;
171 GNUNET_SCHEDULER_cancel (sched, err_task); 170 GNUNET_SCHEDULER_cancel (err_task);
172 GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL); 171 GNUNET_SCHEDULER_add_now (&terminate_task, NULL);
173 return GNUNET_OK; 172 return GNUNET_OK;
174} 173}
175 174
@@ -194,8 +193,7 @@ transmit_ready (void *cls, size_t size, void *buf)
194 m->type = htons (MTYPE); 193 m->type = htons (MTYPE);
195 m->size = htons (sizeof (struct GNUNET_MessageHeader)); 194 m->size = htons (sizeof (struct GNUNET_MessageHeader));
196 err_task = 195 err_task =
197 GNUNET_SCHEDULER_add_delayed (sched, 196 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120), &terminate_task_error, NULL);
198 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120), &terminate_task_error, NULL);
199 197
200 return sizeof (struct GNUNET_MessageHeader); 198 return sizeof (struct GNUNET_MessageHeader);
201} 199}
@@ -221,8 +219,7 @@ init_notify (void *cls,
221 GNUNET_assert (ok == 2); 219 GNUNET_assert (ok == 2);
222 OKPP; 220 OKPP;
223 /* connect p2 */ 221 /* connect p2 */
224 GNUNET_CORE_connect (sched, 222 GNUNET_CORE_connect (p2.cfg,
225 p2.cfg,
226 TIMEOUT, 223 TIMEOUT,
227 &p2, 224 &p2,
228 &init_notify, 225 &init_notify,
@@ -297,7 +294,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
297 "-c", cfgname, NULL); 294 "-c", cfgname, NULL);
298#endif 295#endif
299 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 296 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
300 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); 297 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
301 GNUNET_assert (p->th != NULL); 298 GNUNET_assert (p->th != NULL);
302 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); 299 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
303} 300}
@@ -305,18 +302,15 @@ setup_peer (struct PeerContext *p, const char *cfgname)
305 302
306static void 303static void
307run (void *cls, 304run (void *cls,
308 struct GNUNET_SCHEDULER_Handle *s,
309 char *const *args, 305 char *const *args,
310 const char *cfgfile, 306 const char *cfgfile,
311 const struct GNUNET_CONFIGURATION_Handle *cfg) 307 const struct GNUNET_CONFIGURATION_Handle *cfg)
312{ 308{
313 GNUNET_assert (ok == 1); 309 GNUNET_assert (ok == 1);
314 OKPP; 310 OKPP;
315 sched = s;
316 setup_peer (&p1, "test_core_api_peer1.conf"); 311 setup_peer (&p1, "test_core_api_peer1.conf");
317 setup_peer (&p2, "test_core_api_peer2.conf"); 312 setup_peer (&p2, "test_core_api_peer2.conf");
318 GNUNET_CORE_connect (sched, 313 GNUNET_CORE_connect (p1.cfg,
319 p1.cfg,
320 TIMEOUT, 314 TIMEOUT,
321 &p1, 315 &p1,
322 &init_notify, 316 &init_notify,
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index 49fe8f9de..da67bb4d4 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -82,8 +82,6 @@ static struct PeerContext p1;
82 82
83static struct PeerContext p2; 83static struct PeerContext p2;
84 84
85static struct GNUNET_SCHEDULER_Handle *sched;
86
87static int ok; 85static int ok;
88 86
89#if VERBOSE 87#if VERBOSE
@@ -235,8 +233,8 @@ process_mtype (void *cls,
235 n, s, 233 n, s,
236 ntohs (message->size), 234 ntohs (message->size),
237 ntohl (hdr->num)); 235 ntohl (hdr->num));
238 GNUNET_SCHEDULER_cancel (sched, err_task); 236 GNUNET_SCHEDULER_cancel (err_task);
239 err_task = GNUNET_SCHEDULER_add_now (sched, &terminate_task_error, NULL); 237 err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL);
240 return GNUNET_SYSERR; 238 return GNUNET_SYSERR;
241 } 239 }
242 if (ntohl (hdr->num) != n) 240 if (ntohl (hdr->num) != n)
@@ -246,8 +244,8 @@ process_mtype (void *cls,
246 n, s, 244 n, s,
247 ntohs (message->size), 245 ntohs (message->size),
248 ntohl (hdr->num)); 246 ntohl (hdr->num));
249 GNUNET_SCHEDULER_cancel (sched, err_task); 247 GNUNET_SCHEDULER_cancel (err_task);
250 err_task = GNUNET_SCHEDULER_add_now (sched, &terminate_task_error, NULL); 248 err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL);
251 return GNUNET_SYSERR; 249 return GNUNET_SYSERR;
252 } 250 }
253#if VERBOSE 251#if VERBOSE
@@ -261,8 +259,8 @@ process_mtype (void *cls,
261 fprintf (stderr, "."); 259 fprintf (stderr, ".");
262 if (n == TOTAL_MSGS) 260 if (n == TOTAL_MSGS)
263 { 261 {
264 GNUNET_SCHEDULER_cancel (sched, err_task); 262 GNUNET_SCHEDULER_cancel (err_task);
265 GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL); 263 GNUNET_SCHEDULER_add_now (&terminate_task, NULL);
266 } 264 }
267 else 265 else
268 { 266 {
@@ -334,10 +332,9 @@ transmit_ready (void *cls, size_t size, void *buf)
334 break; /* sometimes pack buffer full, sometimes not */ 332 break; /* sometimes pack buffer full, sometimes not */
335 } 333 }
336 while (size - ret >= s); 334 while (size - ret >= s);
337 GNUNET_SCHEDULER_cancel (sched, err_task); 335 GNUNET_SCHEDULER_cancel (err_task);
338 err_task = 336 err_task =
339 GNUNET_SCHEDULER_add_delayed (sched, 337 GNUNET_SCHEDULER_add_delayed (TIMEOUT,
340 TIMEOUT,
341 &terminate_task_error, 338 &terminate_task_error,
342 NULL); 339 NULL);
343 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 340 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -368,8 +365,7 @@ init_notify (void *cls,
368 GNUNET_assert (ok == 2); 365 GNUNET_assert (ok == 2);
369 OKPP; 366 OKPP;
370 /* connect p2 */ 367 /* connect p2 */
371 GNUNET_CORE_connect (sched, 368 GNUNET_CORE_connect (p2.cfg,
372 p2.cfg,
373 TIMEOUT, 369 TIMEOUT,
374 &p2, 370 &p2,
375 &init_notify, 371 &init_notify,
@@ -389,8 +385,7 @@ init_notify (void *cls,
389 "Asking core (1) for transmission to peer `%4s'\n", 385 "Asking core (1) for transmission to peer `%4s'\n",
390 GNUNET_i2s (&p2.id)); 386 GNUNET_i2s (&p2.id));
391 err_task = 387 err_task =
392 GNUNET_SCHEDULER_add_delayed (sched, 388 GNUNET_SCHEDULER_add_delayed (TIMEOUT,
393 TIMEOUT,
394 &terminate_task_error, 389 &terminate_task_error,
395 NULL); 390 NULL);
396 start_time = GNUNET_TIME_absolute_get (); 391 start_time = GNUNET_TIME_absolute_get ();
@@ -444,7 +439,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
444 "-c", cfgname, NULL); 439 "-c", cfgname, NULL);
445#endif 440#endif
446 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 441 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
447 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); 442 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
448 GNUNET_assert (p->th != NULL); 443 GNUNET_assert (p->th != NULL);
449 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); 444 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
450} 445}
@@ -452,18 +447,15 @@ setup_peer (struct PeerContext *p, const char *cfgname)
452 447
453static void 448static void
454run (void *cls, 449run (void *cls,
455 struct GNUNET_SCHEDULER_Handle *s,
456 char *const *args, 450 char *const *args,
457 const char *cfgfile, 451 const char *cfgfile,
458 const struct GNUNET_CONFIGURATION_Handle *cfg) 452 const struct GNUNET_CONFIGURATION_Handle *cfg)
459{ 453{
460 GNUNET_assert (ok == 1); 454 GNUNET_assert (ok == 1);
461 OKPP; 455 OKPP;
462 sched = s;
463 setup_peer (&p1, "test_core_api_peer1.conf"); 456 setup_peer (&p1, "test_core_api_peer1.conf");
464 setup_peer (&p2, "test_core_api_peer2.conf"); 457 setup_peer (&p2, "test_core_api_peer2.conf");
465 GNUNET_CORE_connect (sched, 458 GNUNET_CORE_connect (p1.cfg,
466 p1.cfg,
467 TIMEOUT, 459 TIMEOUT,
468 &p1, 460 &p1,
469 &init_notify, 461 &init_notify,
diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c
index 958defbf9..da7217f39 100644
--- a/src/core/test_core_api_start_only.c
+++ b/src/core/test_core_api_start_only.c
@@ -57,7 +57,6 @@ static struct PeerContext p1;
57 57
58static struct PeerContext p2; 58static struct PeerContext p2;
59 59
60static struct GNUNET_SCHEDULER_Handle *sched;
61 60
62static int ok; 61static int ok;
63 62
@@ -126,8 +125,7 @@ init_notify (void *cls,
126 if (cls == &p1) 125 if (cls == &p1)
127 { 126 {
128 /* connect p2 */ 127 /* connect p2 */
129 GNUNET_CORE_connect (sched, 128 GNUNET_CORE_connect (p2.cfg,
130 p2.cfg,
131 TIMEOUT, 129 TIMEOUT,
132 &p2, 130 &p2,
133 &init_notify, 131 &init_notify,
@@ -166,18 +164,15 @@ setup_peer (struct PeerContext *p, const char *cfgname)
166 164
167static void 165static void
168run (void *cls, 166run (void *cls,
169 struct GNUNET_SCHEDULER_Handle *s,
170 char *const *args, 167 char *const *args,
171 const char *cfgfile, 168 const char *cfgfile,
172 const struct GNUNET_CONFIGURATION_Handle *cfg) 169 const struct GNUNET_CONFIGURATION_Handle *cfg)
173{ 170{
174 GNUNET_assert (ok == 1); 171 GNUNET_assert (ok == 1);
175 OKPP; 172 OKPP;
176 sched = s;
177 setup_peer (&p1, "test_core_api_peer1.conf"); 173 setup_peer (&p1, "test_core_api_peer1.conf");
178 setup_peer (&p2, "test_core_api_peer2.conf"); 174 setup_peer (&p2, "test_core_api_peer2.conf");
179 GNUNET_CORE_connect (sched, 175 GNUNET_CORE_connect (p1.cfg,
180 p1.cfg,
181 TIMEOUT, 176 TIMEOUT,
182 &p1, 177 &p1,
183 &init_notify, 178 &init_notify,
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index d69fb0905..822dc2c46 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -105,8 +105,6 @@ static struct PeerContext p1;
105 105
106static struct PeerContext p2; 106static struct PeerContext p2;
107 107
108static struct GNUNET_SCHEDULER_Handle *sched;
109
110static int ok; 108static int ok;
111static int measurement_running; 109static int measurement_running;
112 110
@@ -147,7 +145,7 @@ terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
147{ 145{
148 GNUNET_break (0); 146 GNUNET_break (0);
149 if (send_task != GNUNET_SCHEDULER_NO_TASK) 147 if (send_task != GNUNET_SCHEDULER_NO_TASK)
150 GNUNET_SCHEDULER_cancel (sched,send_task); 148 GNUNET_SCHEDULER_cancel (send_task);
151 GNUNET_CORE_disconnect (p1.ch); 149 GNUNET_CORE_disconnect (p1.ch);
152 p1.ch = NULL; 150 p1.ch = NULL;
153 GNUNET_CORE_disconnect (p2.ch); 151 GNUNET_CORE_disconnect (p2.ch);
@@ -247,9 +245,9 @@ measurement_end (void *cls,
247 return; 245 return;
248 246
249 if (err_task != GNUNET_SCHEDULER_NO_TASK) 247 if (err_task != GNUNET_SCHEDULER_NO_TASK)
250 GNUNET_SCHEDULER_cancel (sched, err_task); 248 GNUNET_SCHEDULER_cancel (err_task);
251 if (send_task != GNUNET_SCHEDULER_NO_TASK) 249 if (send_task != GNUNET_SCHEDULER_NO_TASK)
252 GNUNET_SCHEDULER_cancel (sched,send_task); 250 GNUNET_SCHEDULER_cancel (send_task);
253 251
254 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1); 252 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p1);
255 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2); 253 GNUNET_STATISTICS_get(p1.stats,"core","# discarded CORE_SEND requests",GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_2, &p2);
@@ -271,7 +269,7 @@ measurement_end (void *cls,
271 (total_bytes_sent/(duration.rel_value / 1000)/1024),current_quota_p1_in/1024); 269 (total_bytes_sent/(duration.rel_value / 1000)/1024),current_quota_p1_in/1024);
272 270
273 271
274 GNUNET_SCHEDULER_add_now (sched, &terminate_task, NULL); 272 GNUNET_SCHEDULER_add_now (&terminate_task, NULL);
275} 273}
276 274
277static size_t 275static size_t
@@ -307,12 +305,10 @@ static void measure (unsigned long long quota_p1, unsigned long long quota_p2 )
307 "Asking core (1) for transmission to peer `%4s'\n", 305 "Asking core (1) for transmission to peer `%4s'\n",
308 GNUNET_i2s (&p2.id)); 306 GNUNET_i2s (&p2.id));
309#endif 307#endif
310 err_task = GNUNET_SCHEDULER_add_delayed (sched, 308 err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
311 TIMEOUT,
312 &terminate_task_error, 309 &terminate_task_error,
313 NULL); 310 NULL);
314 measure_task = GNUNET_SCHEDULER_add_delayed (sched, 311 measure_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL,
315 MEASUREMENT_INTERVALL,
316 &measurement_end, 312 &measurement_end,
317 NULL); 313 NULL);
318 start_time = GNUNET_TIME_absolute_get (); 314 start_time = GNUNET_TIME_absolute_get ();
@@ -420,17 +416,16 @@ transmit_ready (void *cls, size_t size, void *buf)
420 break; /* sometimes pack buffer full, sometimes not */ 416 break; /* sometimes pack buffer full, sometimes not */
421 } 417 }
422 while (size - ret >= s); 418 while (size - ret >= s);
423 GNUNET_SCHEDULER_cancel (sched, err_task); 419 GNUNET_SCHEDULER_cancel (err_task);
424 err_task = GNUNET_SCHEDULER_add_delayed (sched, 420 err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
425 TIMEOUT,
426 &terminate_task_error, 421 &terminate_task_error,
427 NULL); 422 NULL);
428 423
429 total_bytes += ret; 424 total_bytes += ret;
430 total_bytes_sent += ret; 425 total_bytes_sent += ret;
431 if (send_task != GNUNET_SCHEDULER_NO_TASK) 426 if (send_task != GNUNET_SCHEDULER_NO_TASK)
432 GNUNET_SCHEDULER_cancel(sched, send_task); 427 GNUNET_SCHEDULER_cancel(send_task);
433 send_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 20), &send_tsk, NULL); 428 send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 20), &send_tsk, NULL);
434 429
435 return ret; 430 return ret;
436} 431}
@@ -457,8 +452,7 @@ init_notify (void *cls,
457 GNUNET_assert (ok == 2); 452 GNUNET_assert (ok == 2);
458 OKPP; 453 OKPP;
459 /* connect p2 */ 454 /* connect p2 */
460 GNUNET_CORE_connect (sched, 455 GNUNET_CORE_connect (p2.cfg,
461 p2.cfg,
462 TIMEOUT, 456 TIMEOUT,
463 &p2, 457 &p2,
464 &init_notify, 458 &init_notify,
@@ -521,9 +515,9 @@ setup_peer (struct PeerContext *p, const char *cfgname)
521 "-c", cfgname, NULL); 515 "-c", cfgname, NULL);
522#endif 516#endif
523 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 517 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
524 p->stats = GNUNET_STATISTICS_create (sched, "core", p->cfg); 518 p->stats = GNUNET_STATISTICS_create ("core", p->cfg);
525 GNUNET_assert (p->stats != NULL); 519 GNUNET_assert (p->stats != NULL);
526 p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, NULL, p, NULL, NULL, NULL); 520 p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
527 GNUNET_assert (p->th != NULL); 521 GNUNET_assert (p->th != NULL);
528 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); 522 GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
529} 523}
@@ -531,18 +525,15 @@ setup_peer (struct PeerContext *p, const char *cfgname)
531 525
532static void 526static void
533run (void *cls, 527run (void *cls,
534 struct GNUNET_SCHEDULER_Handle *s,
535 char *const *args, 528 char *const *args,
536 const char *cfgfile, 529 const char *cfgfile,
537 const struct GNUNET_CONFIGURATION_Handle *cfg) 530 const struct GNUNET_CONFIGURATION_Handle *cfg)
538{ 531{
539 GNUNET_assert (ok == 1); 532 GNUNET_assert (ok == 1);
540 OKPP; 533 OKPP;
541 sched = s;
542 setup_peer (&p1, "test_core_quota_peer1.conf"); 534 setup_peer (&p1, "test_core_quota_peer1.conf");
543 setup_peer (&p2, "test_core_quota_peer2.conf"); 535 setup_peer (&p2, "test_core_quota_peer2.conf");
544 GNUNET_CORE_connect (sched, 536 GNUNET_CORE_connect (p1.cfg,
545 p1.cfg,
546 TIMEOUT, 537 TIMEOUT,
547 &p1, 538 &p1,
548 &init_notify, 539 &init_notify,