aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-14 11:12:46 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-14 11:12:46 +0000
commita2ed50e8e82e1d4f60302c30f9d748f7698b7cec (patch)
tree223239f9e17b485924c8cd52b8bd55f657061d7b /src
parent53da062e08f1d1d4392b3a40396bb45cc093e2ac (diff)
downloadgnunet-a2ed50e8e82e1d4f60302c30f9d748f7698b7cec.tar.gz
gnunet-a2ed50e8e82e1d4f60302c30f9d748f7698b7cec.zip
remove getter, make global static, add closure argument
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_scheduler_lib.h26
-rw-r--r--src/util/disk.h2
-rw-r--r--src/util/scheduler.c38
3 files changed, 29 insertions, 37 deletions
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h
index 6b927bba8..723f8ca91 100644
--- a/src/include/gnunet_scheduler_lib.h
+++ b/src/include/gnunet_scheduler_lib.h
@@ -198,16 +198,18 @@ typedef void (*GNUNET_SCHEDULER_Task) (void *cls,
198 * Signature of the select function used by the scheduler. 198 * Signature of the select function used by the scheduler.
199 * GNUNET_NETWORK_socket_select matches it. 199 * GNUNET_NETWORK_socket_select matches it.
200 * 200 *
201 * @param cls closure
201 * @param rfds set of sockets to be checked for readability 202 * @param rfds set of sockets to be checked for readability
202 * @param wfds set of sockets to be checked for writability 203 * @param wfds set of sockets to be checked for writability
203 * @param efds set of sockets to be checked for exceptions 204 * @param efds set of sockets to be checked for exceptions
204 * @param timeout relative value when to return 205 * @param timeout relative value when to return
205 * @return number of selected sockets, GNUNET_SYSERR on error 206 * @return number of selected sockets, GNUNET_SYSERR on error
206 */ 207 */
207typedef int (*GNUNET_SCHEDULER_select) (struct GNUNET_NETWORK_FDSet *rfds, 208typedef int (*GNUNET_SCHEDULER_select) (void *cls,
208 struct GNUNET_NETWORK_FDSet *wfds, 209 struct GNUNET_NETWORK_FDSet *rfds,
209 struct GNUNET_NETWORK_FDSet *efds, 210 struct GNUNET_NETWORK_FDSet *wfds,
210 struct GNUNET_TIME_Relative timeout); 211 struct GNUNET_NETWORK_FDSet *efds,
212 struct GNUNET_TIME_Relative timeout);
211/** 213/**
212 * Initialize and run scheduler. This function will return when all 214 * Initialize and run scheduler. This function will return when all
213 * tasks have completed. On systems with signals, receiving a SIGTERM 215 * tasks have completed. On systems with signals, receiving a SIGTERM
@@ -511,19 +513,13 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio,
511/** 513/**
512 * Sets the select function to use in the scheduler (scheduler_select). 514 * Sets the select function to use in the scheduler (scheduler_select).
513 * 515 *
514 * @param new_select new select function to use 516 * @param new_select new select function to use (NULL to reset to default)
515 * @return previously used select function 517 * @param new_select_cls closure for 'new_select'
516 */ 518 */
517GNUNET_SCHEDULER_select 519void
518GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select); 520GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select,
521 void *new_select_cls);
519 522
520/**
521 * Gets the select function currently used in the scheduler.
522 *
523 * @return currently used select function
524 */
525GNUNET_SCHEDULER_select
526GNUNET_SCHEDULER_get_select ();
527 523
528#if 0 /* keep Emacsens' auto-indent happy */ 524#if 0 /* keep Emacsens' auto-indent happy */
529{ 525{
diff --git a/src/util/disk.h b/src/util/disk.h
index fee43abb8..0f094e289 100644
--- a/src/util/disk.h
+++ b/src/util/disk.h
@@ -28,8 +28,6 @@
28 28
29#include "gnunet_disk_lib.h" 29#include "gnunet_disk_lib.h"
30 30
31};
32
33/** 31/**
34 * Retrieve OS file handle 32 * Retrieve OS file handle
35 * 33 *
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 692c4f0b7..d7f9a293b 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -247,36 +247,29 @@ static int current_lifeness;
247 247
248/** 248/**
249 * Function to use as a select() in the scheduler. 249 * Function to use as a select() in the scheduler.
250 * Defaults to GNUNET_NETWORK_socket_select () 250 * If NULL, we use GNUNET_NETWORK_socket_select ().
251 */ 251 */
252GNUNET_SCHEDULER_select scheduler_select = GNUNET_NETWORK_socket_select; 252static GNUNET_SCHEDULER_select scheduler_select;
253
254/**
255 * Closure for 'scheduler_select'.
256 */
257static void *scheduler_select_cls;
253 258
254/** 259/**
255 * Sets the select function to use in the scheduler (scheduler_select). 260 * Sets the select function to use in the scheduler (scheduler_select).
256 * 261 *
257 * @param new_select new select function to use 262 * @param new_select new select function to use
258 * @return previously used select function 263 * @return previously used select function, NULL for default
259 */ 264 */
260GNUNET_SCHEDULER_select 265void
261GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select) 266GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select,
267 void *new_select_cls)
262{ 268{
263 GNUNET_SCHEDULER_select old_select = scheduler_select;
264 scheduler_select = new_select; 269 scheduler_select = new_select;
265 if (scheduler_select == NULL) 270 scheduler_select_cls = new_select_cls;
266 scheduler_select = GNUNET_NETWORK_socket_select;
267 return old_select;
268} 271}
269 272
270/**
271 * Gets the select function currently used in the scheduler.
272 *
273 * @return currently used select function
274 */
275GNUNET_SCHEDULER_select
276GNUNET_SCHEDULER_get_select ()
277{
278 return scheduler_select;
279}
280 273
281/** 274/**
282 * Check that the given priority is legal (and return it). 275 * Check that the given priority is legal (and return it).
@@ -839,7 +832,12 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
839 /* no blocking, more work already ready! */ 832 /* no blocking, more work already ready! */
840 timeout = GNUNET_TIME_UNIT_ZERO; 833 timeout = GNUNET_TIME_UNIT_ZERO;
841 } 834 }
842 ret = scheduler_select (rs, ws, NULL, timeout); 835 if (NULL == scheduler_select)
836 ret = GNUNET_NETWORK_socket_select (rs, ws, NULL, timeout);
837 else
838 ret = scheduler_select (scheduler_select_cls,
839 rs, ws, NULL,
840 timeout);
843 if (ret == GNUNET_SYSERR) 841 if (ret == GNUNET_SYSERR)
844 { 842 {
845 if (errno == EINTR) 843 if (errno == EINTR)