aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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 6b927bba87..723f8ca914 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,
* Signature of the select function used by the scheduler.
* GNUNET_NETWORK_socket_select matches it.
*
+ * @param cls closure
* @param rfds set of sockets to be checked for readability
* @param wfds set of sockets to be checked for writability
* @param efds set of sockets to be checked for exceptions
* @param timeout relative value when to return
* @return number of selected sockets, GNUNET_SYSERR on error
*/
-typedef int (*GNUNET_SCHEDULER_select) (struct GNUNET_NETWORK_FDSet *rfds,
- struct GNUNET_NETWORK_FDSet *wfds,
- struct GNUNET_NETWORK_FDSet *efds,
- struct GNUNET_TIME_Relative timeout);
+typedef int (*GNUNET_SCHEDULER_select) (void *cls,
+ struct GNUNET_NETWORK_FDSet *rfds,
+ struct GNUNET_NETWORK_FDSet *wfds,
+ struct GNUNET_NETWORK_FDSet *efds,
+ struct GNUNET_TIME_Relative timeout);
/**
* Initialize and run scheduler. This function will return when all
* tasks have completed. On systems with signals, receiving a SIGTERM
@@ -511,19 +513,13 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio,
/**
* Sets the select function to use in the scheduler (scheduler_select).
*
- * @param new_select new select function to use
- * @return previously used select function
+ * @param new_select new select function to use (NULL to reset to default)
+ * @param new_select_cls closure for 'new_select'
*/
-GNUNET_SCHEDULER_select
-GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select);
+void
+GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select,
+ void *new_select_cls);
-/**
- * Gets the select function currently used in the scheduler.
- *
- * @return currently used select function
- */
-GNUNET_SCHEDULER_select
-GNUNET_SCHEDULER_get_select ();
#if 0 /* keep Emacsens' auto-indent happy */
{
diff --git a/src/util/disk.h b/src/util/disk.h
index fee43abb87..0f094e2896 100644
--- a/src/util/disk.h
+++ b/src/util/disk.h
@@ -28,8 +28,6 @@
#include "gnunet_disk_lib.h"
-};
-
/**
* Retrieve OS file handle
*
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 692c4f0b7a..d7f9a293b7 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -247,36 +247,29 @@ static int current_lifeness;
/**
* Function to use as a select() in the scheduler.
- * Defaults to GNUNET_NETWORK_socket_select ()
+ * If NULL, we use GNUNET_NETWORK_socket_select ().
*/
-GNUNET_SCHEDULER_select scheduler_select = GNUNET_NETWORK_socket_select;
+static GNUNET_SCHEDULER_select scheduler_select;
+
+/**
+ * Closure for 'scheduler_select'.
+ */
+static void *scheduler_select_cls;
/**
* Sets the select function to use in the scheduler (scheduler_select).
*
* @param new_select new select function to use
- * @return previously used select function
+ * @return previously used select function, NULL for default
*/
-GNUNET_SCHEDULER_select
-GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select)
+void
+GNUNET_SCHEDULER_set_select (GNUNET_SCHEDULER_select new_select,
+ void *new_select_cls)
{
- GNUNET_SCHEDULER_select old_select = scheduler_select;
scheduler_select = new_select;
- if (scheduler_select == NULL)
- scheduler_select = GNUNET_NETWORK_socket_select;
- return old_select;
+ scheduler_select_cls = new_select_cls;
}
-/**
- * Gets the select function currently used in the scheduler.
- *
- * @return currently used select function
- */
-GNUNET_SCHEDULER_select
-GNUNET_SCHEDULER_get_select ()
-{
- return scheduler_select;
-}
/**
* Check that the given priority is legal (and return it).
@@ -839,7 +832,12 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
/* no blocking, more work already ready! */
timeout = GNUNET_TIME_UNIT_ZERO;
}
- ret = scheduler_select (rs, ws, NULL, timeout);
+ if (NULL == scheduler_select)
+ ret = GNUNET_NETWORK_socket_select (rs, ws, NULL, timeout);
+ else
+ ret = scheduler_select (scheduler_select_cls,
+ rs, ws, NULL,
+ timeout);
if (ret == GNUNET_SYSERR)
{
if (errno == EINTR)