[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 16/45: lifeness checks; shutdown now working; chec
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 16/45: lifeness checks; shutdown now working; checkSignal not passing yet |
Date: |
Sun, 31 Dec 2017 00:37:03 +0100 |
This is an automated email from the git hooks/post-receive script.
lurchi pushed a commit to branch master
in repository gnunet.
commit b44cf84da67b78b4022009321a01376d74530685
Author: lurchi <address@hidden>
AuthorDate: Wed Aug 9 19:21:30 2017 +0200
lifeness checks; shutdown now working; checkSignal not passing yet
---
src/util/scheduler.c | 129 +++++++++++++++++++++++++++++++--------------------
1 file changed, 78 insertions(+), 51 deletions(-)
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index c7471ee0b..e1b6b4b51 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -583,29 +583,29 @@ sighandler_shutdown ()
* @return #GNUNET_OK to continue the main loop,
* #GNUNET_NO to exit
*/
-//static int
-//check_lifeness ()
-//{
-// struct GNUNET_SCHEDULER_Task *t;
-//
-// if (ready_count > 0)
-// return GNUNET_OK;
-// for (t = pending_head; NULL != t; t = t->next)
-// if (t->lifeness == GNUNET_YES)
-// return GNUNET_OK;
-// for (t = shutdown_head; NULL != t; t = t->next)
-// if (t->lifeness == GNUNET_YES)
-// return GNUNET_OK;
-// for (t = pending_timeout_head; NULL != t; t = t->next)
-// if (t->lifeness == GNUNET_YES)
-// return GNUNET_OK;
-// if (NULL != shutdown_head)
-// {
-// GNUNET_SCHEDULER_shutdown ();
-// return GNUNET_OK;
-// }
-// return GNUNET_NO;
-//}
+static int
+check_lifeness ()
+{
+ struct GNUNET_SCHEDULER_Task *t;
+
+ if (ready_count > 0)
+ return GNUNET_OK;
+ for (t = pending_head; NULL != t; t = t->next)
+ if (t->lifeness == GNUNET_YES)
+ return GNUNET_OK;
+ for (t = shutdown_head; NULL != t; t = t->next)
+ if (t->lifeness == GNUNET_YES)
+ return GNUNET_OK;
+ for (t = pending_timeout_head; NULL != t; t = t->next)
+ if (t->lifeness == GNUNET_YES)
+ return GNUNET_OK;
+ if (NULL != shutdown_head)
+ {
+ GNUNET_SCHEDULER_shutdown ();
+ return GNUNET_OK;
+ }
+ return GNUNET_NO;
+}
/**
@@ -1652,7 +1652,6 @@ GNUNET_SCHEDULER_task_ready (struct GNUNET_SCHEDULER_Task
*task,
int
GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh)
{
- // FIXME: we have to check lifeness here!
enum GNUNET_SCHEDULER_Priority p;
struct GNUNET_SCHEDULER_Task *pos;
struct GNUNET_TIME_Absolute now;
@@ -1735,10 +1734,29 @@ GNUNET_SCHEDULER_run_from_driver (struct
GNUNET_SCHEDULER_Handle *sh)
destroy_task (pos);
tasks_run++;
}
- scheduler_driver->set_wakeup (scheduler_driver->cls,
- get_timeout ());
+ if (GNUNET_NO == check_lifeness ())
+ {
+ /* cancel fd tasks without lifeness */
+ pos = pending_head;
+ while (NULL != pos)
+ {
+ struct GNUNET_SCHEDULER_Task *tsk = pos;
+ pos = pos->next;
+ if (GNUNET_NO == tsk->lifeness)
+ {
+ GNUNET_SCHEDULER_cancel (tsk);
+ }
+ }
+ //sighandler_shutdown();
+ }
if (0 == ready_count)
+ {
+ scheduler_driver->set_wakeup (scheduler_driver->cls,
+ get_timeout ());
return GNUNET_NO;
+ }
+ scheduler_driver->set_wakeup (scheduler_driver->cls,
+ GNUNET_TIME_absolute_get ());
return GNUNET_OK;
}
@@ -1812,23 +1830,40 @@ GNUNET_SCHEDULER_run_with_driver (const struct
GNUNET_SCHEDULER_Driver *driver,
#endif
/* Setup initial tasks */
+ //current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT;
+ //current_lifeness = GNUNET_YES;
+ //memset (&tsk,
+ // 0,
+ // sizeof (tsk));
+ //active_task = &tsk;
+ //GNUNET_SCHEDULER_add_with_reason_and_priority (task,
+ // task_cls,
+ //
GNUNET_SCHEDULER_REASON_STARTUP,
+ //
GNUNET_SCHEDULER_PRIORITY_DEFAULT);
+ //GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO,
+ //
&GNUNET_OS_install_parent_control_handler,
+ // NULL);
+ //GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
+ // pr,
+ // &shutdown_task,
+ // NULL);
current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT;
- current_lifeness = GNUNET_YES;
+ current_lifeness = GNUNET_NO;
memset (&tsk,
0,
sizeof (tsk));
active_task = &tsk;
- GNUNET_SCHEDULER_add_with_reason_and_priority (task,
- task_cls,
-
GNUNET_SCHEDULER_REASON_STARTUP,
-
GNUNET_SCHEDULER_PRIORITY_DEFAULT);
- GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO,
-
&GNUNET_OS_install_parent_control_handler,
- NULL);
+ GNUNET_SCHEDULER_add_now (&GNUNET_OS_install_parent_control_handler,
+ NULL);
GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
pr,
&shutdown_task,
NULL);
+ current_lifeness = GNUNET_YES;
+ GNUNET_SCHEDULER_add_with_reason_and_priority (task,
+ task_cls,
+
GNUNET_SCHEDULER_REASON_STARTUP,
+
GNUNET_SCHEDULER_PRIORITY_DEFAULT);
active_task = NULL;
/* begin main event loop */
sh.rs = GNUNET_NETWORK_fdset_create ();
@@ -1837,7 +1872,7 @@ GNUNET_SCHEDULER_run_with_driver (const struct
GNUNET_SCHEDULER_Driver *driver,
ret = driver->loop (driver->cls,
&sh);
LOG (GNUNET_ERROR_TYPE_WARNING,
- "loop finished!");
+ "loop finished!\n");
GNUNET_NETWORK_fdset_destroy (sh.rs);
GNUNET_NETWORK_fdset_destroy (sh.ws);
@@ -1912,6 +1947,7 @@ select_del (void *cls,
int ret = GNUNET_SYSERR;
struct Scheduled *pos;
+ // FIXME: are multiple ORed event types allowed?
switch (fdi->et)
{
case GNUNET_SCHEDULER_ET_IN:
@@ -1952,13 +1988,6 @@ select_del (void *cls,
}
-//int
-//select_loop_condition (const struct DriverContext *context)
-//{
-// struct GNUNET_TIME_absolute_
-//}
-
-
int
select_loop (void *cls,
struct GNUNET_SCHEDULER_Handle *sh)
@@ -1976,8 +2005,7 @@ select_loop (void *cls,
ws = GNUNET_NETWORK_fdset_create ();
last_tr = 0;
busy_wait_warning = 0;
- while ((NULL != context->scheduled_in_head) ||
- (NULL != context->scheduled_out_head))
+ while ((NULL != context->scheduled_in_head) || (NULL !=
context->scheduled_out_head))
{
GNUNET_NETWORK_fdset_zero (rs);
GNUNET_NETWORK_fdset_zero (ws);
@@ -1990,11 +2018,6 @@ select_loop (void *cls,
{
GNUNET_NETWORK_fdset_set_native (ws, pos->fdi->sock);
}
- if (ready_count > 0)
- {
- /* no blocking, more work already ready! */
- context->timeout = GNUNET_TIME_UNIT_ZERO;
- }
if (NULL == scheduler_select)
{
select_result = GNUNET_NETWORK_socket_select (rs,
@@ -2071,20 +2094,20 @@ select_loop (void *cls,
{
if (GNUNET_YES == GNUNET_NETWORK_fdset_test_native (rs, pos->fdi->sock))
{
- GNUNET_SCHEDULER_task_ready (pos->task, GNUNET_SCHEDULER_ET_IN);
GNUNET_CONTAINER_DLL_remove (context->scheduled_in_head,
context->scheduled_in_tail,
pos);
+ GNUNET_SCHEDULER_task_ready (pos->task, GNUNET_SCHEDULER_ET_IN);
}
}
for (pos = context->scheduled_out_head; NULL != pos; pos = pos->next)
{
if (GNUNET_YES == GNUNET_NETWORK_fdset_test_native (ws, pos->fdi->sock))
{
- GNUNET_SCHEDULER_task_ready (pos->task, GNUNET_SCHEDULER_ET_OUT);
GNUNET_CONTAINER_DLL_remove (context->scheduled_out_head,
context->scheduled_out_tail,
pos);
+ GNUNET_SCHEDULER_task_ready (pos->task, GNUNET_SCHEDULER_ET_OUT);
}
}
GNUNET_SCHEDULER_run_from_driver (sh);
@@ -2098,6 +2121,10 @@ select_loop (void *cls,
last_tr = tasks_run;
busy_wait_warning = 0;
}
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "scheduled_in_head = %p, scheduled_out_head = %p\n",
+ context->scheduled_in_head,
+ context->scheduled_out_head);
}
return GNUNET_OK;
}
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] 06/45: GNUNET_SCHEDULER_run is calling GNUNET_SCHEDULER_run_with_driver with the default select polling backend., (continued)
- [GNUnet-SVN] [gnunet] 06/45: GNUNET_SCHEDULER_run is calling GNUNET_SCHEDULER_run_with_driver with the default select polling backend., gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 03/45: adapt add_without_sets to scheduler driver API; reimplement initFdInfo, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 05/45: Call to set_wakeup added after tasks added/removed to/from pending_timeout, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 04/45: Nearly finished. Call to set_wakeup missing in case of tasks added to pending_timeout, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 08/45: fix warnings, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 09/45: add missing DLL insert, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 07/45: make input of getters const (needed for new scheduler API), gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 13/45: Merge branch 'refactoring-scheduler' of ssh://gnunet.org/gnunet, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 18/45: cosmetic fixes, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 17/45: test_scheduler passing; new API function GNUNET_SCHEDULER_check_lifeness, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 16/45: lifeness checks; shutdown now working; checkSignal not passing yet,
gnunet <=
- [GNUnet-SVN] [gnunet] 15/45: fix initFdInfo; rename to init_fd_info, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 10/45: fix segfault and pending_timeout logic, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 11/45: Smaller changes. Changed order when set_wakeup is called after some task is removed from pending_timeout, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 20/45: remove unnecessary set_wakup call, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 14/45: fix indentation; remove unneeded set_wakeup call, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 19/45: fix compilation of debug code enabled by DEBUG_FDS; fix indentation, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 25/45: fix off-by-one error that prevented reading from stdin, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 36/45: fix behaviour of GNUNET_SCHEDULER_add_select on empty fdsets, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 39/45: Don't consider restart when the test action already finished, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 35/45: NULL-initialize array pointers, gnunet, 2017/12/30