[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 43/45: Fix select loop running conditions
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 43/45: Fix select loop running conditions |
Date: |
Sun, 31 Dec 2017 00:37:30 +0100 |
This is an automated email from the git hooks/post-receive script.
lurchi pushed a commit to branch master
in repository gnunet.
commit 490c41e78c79a18ab683f83299b041564cb4a69b
Author: lurchi <address@hidden>
AuthorDate: Mon Sep 4 15:05:26 2017 +0200
Fix select loop running conditions
The select loop has to keep running as long as the driver has tasks
available (indicating that there are file descriptors left to wait for)
or the timeout is not FOREVER (indicating that the scheduler has tasks
with timeout left).
---
src/include/gnunet_scheduler_lib.h | 12 ++++++++----
src/util/scheduler.c | 6 +++++-
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/include/gnunet_scheduler_lib.h
b/src/include/gnunet_scheduler_lib.h
index b6f127f0c..aded41de8 100644
--- a/src/include/gnunet_scheduler_lib.h
+++ b/src/include/gnunet_scheduler_lib.h
@@ -242,15 +242,16 @@ struct GNUNET_SCHEDULER_Handle;
* there are tasks left to run just to give other tasks a chance as
* well. If we return #GNUNET_YES, the driver should call this
* function again as soon as possible, while if we return #GNUNET_NO
- * it must block until the operating system has more work as the
- * scheduler has no more work to do right now.
+ * it must block until either the operating system has more work (the
+ * scheduler has no more work to do right now) or the timeout set by
+ * the scheduler (using the set_wakeup callback) is reached.
*
* @param sh scheduler handle that was given to the `loop`
* @return #GNUNET_OK if there are more tasks that are ready,
* and thus we would like to run more (yield to avoid
* blocking other activities for too long)
* #GNUNET_NO if we are done running tasks (yield to block)
- * #GNUNET_SYSERR on error
+ * #GNUNET_SYSERR on error, e.g. no tasks were ready
*/
int
GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh);
@@ -313,7 +314,10 @@ struct GNUNET_SCHEDULER_Driver
/**
* Event loop's "main" function, to be called from
* #GNUNET_SCHEDULER_run_with_driver() to actually
- * launch the loop.
+ * launch the loop. The loop should run as long as
+ * tasks (added by the add callback) are available
+ * OR the wakeup time (added by the set_wakeup
+ * callback) is not FOREVER.
*
* @param cls closure
* @param sh scheduler handle to pass to
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 72f2b7230..4b963209d 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -2209,7 +2209,8 @@ select_loop (void *cls,
rs = GNUNET_NETWORK_fdset_create ();
ws = GNUNET_NETWORK_fdset_create ();
tasks_ready = GNUNET_NO;
- while (NULL != context->scheduled_head || GNUNET_YES == tasks_ready)
+ while (NULL != context->scheduled_head ||
+ GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us !=
context->timeout.rel_value_us)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"select timeout = %s\n",
@@ -2300,6 +2301,9 @@ select_loop (void *cls,
}
tasks_ready = GNUNET_SCHEDULER_run_from_driver (sh);
GNUNET_assert (GNUNET_SYSERR != tasks_ready);
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "select timeout = %s\n",
+ GNUNET_STRINGS_relative_time_to_string (context->timeout, GNUNET_NO));
}
return GNUNET_OK;
}
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] 21/45: set fds_len in all cases; call set_wakeup only in two places, (continued)
- [GNUnet-SVN] [gnunet] 21/45: set fds_len in all cases; call set_wakeup only in two places, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 38/45: clarify documentation about adding / deleting tasks, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 12/45: separate the select driver's fd sets from the driver-internal fdsets, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 40/45: Remove busy waiting checks, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 29/45: implement bookkeeping about which FDs related to a tasks have been marked ready (required API change in GNUNET_SCHEDULER_task_ready), gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 45/45: merge branch 'refactoring-scheduler', gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 26/45: reimplement init_fd_info as preparation for refactoring GNUNET_SCHEDULER_add_select, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 24/45: init_fd_info now completely initializes fd information; Allow calling add/cancel functions only when the scheduler is running, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 42/45: handles, not handlers, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 30/45: only allocate network / file handles and store them in the task when GNUNET_SCHEDULER_add_select is used, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 43/45: Fix select loop running conditions,
gnunet <=
- [GNUnet-SVN] [gnunet] 41/45: remove scheduler->internal code from driver loop, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 32/45: tasks in the pending queue must be be checked for reached timeouts, too; allow multiple event types per FdInfo, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 37/45: Simplify driver callback del; fix shutdown logic, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 44/45: cleanup, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 27/45: add buggy state of refactored GNUNET_SCHEDULER_add_select, gnunet, 2017/12/30