[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 19/45: fix compilation of debug code enabled by DE
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 19/45: fix compilation of debug code enabled by DEBUG_FDS; fix indentation |
Date: |
Sun, 31 Dec 2017 00:37:06 +0100 |
This is an automated email from the git hooks/post-receive script.
lurchi pushed a commit to branch master
in repository gnunet.
commit 4e82b4961abb33ccacf95fa7b3101450230bf10d
Author: lurchi <address@hidden>
AuthorDate: Thu Aug 10 20:05:37 2017 +0200
fix compilation of debug code enabled by DEBUG_FDS; fix indentation
---
src/util/scheduler.c | 63 +++++++++++++++++++++++++++++-----------------------
1 file changed, 35 insertions(+), 28 deletions(-)
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 5a727c663..918460ca7 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -1073,12 +1073,12 @@ GNUNET_SCHEDULER_add_at (struct GNUNET_TIME_Absolute at,
struct GNUNET_SCHEDULER_Task *
GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay,
GNUNET_SCHEDULER_TaskCallback task,
- void *task_cls)
+ void *task_cls)
{
return GNUNET_SCHEDULER_add_delayed_with_priority (delay,
GNUNET_SCHEDULER_PRIORITY_DEFAULT,
task,
- task_cls);
+ task_cls);
}
@@ -1175,6 +1175,33 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness,
}
+#if DEBUG_FDS
+/**
+ * check a raw file descriptor and abort if it is bad (for debugging purposes)
+ *
+ * @param t the task related to the file descriptor
+ * @param raw_fd the raw file descriptor to check
+ */
+void
+check_fd (struct GNUNET_SCHEDULER_Task *t, int raw_fd)
+{
+ if (-1 != raw_fd)
+ {
+ int flags = fcntl (raw_fd, F_GETFD);
+
+ if ((flags == -1) && (errno == EBADF))
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Got invalid file descriptor %d!\n",
+ raw_fd);
+ init_backtrace (t);
+ GNUNET_assert (0);
+ }
+ }
+}
+#endif
+
+
/**
* Schedule a new task to be run with a specified delay or when any of
* the specified file descriptor sets is ready. The delay can be used
@@ -1220,32 +1247,10 @@ add_without_sets (struct GNUNET_TIME_Relative delay,
t->callback = task;
t->callback_cls = task_cls;
#if DEBUG_FDS
- if (-1 != rfd)
- {
- int flags = fcntl (rfd, F_GETFD);
-
- if ((flags == -1) && (errno == EBADF))
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Got invalid file descriptor %d!\n",
- rfd);
- init_backtrace (t);
- GNUNET_assert (0);
- }
- }
- if (-1 != wfd)
- {
- int flags = fcntl (wfd, F_GETFD);
-
- if (flags == -1 && errno == EBADF)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Got invalid file descriptor %d!\n",
- wfd);
- init_backtrace (t);
- GNUNET_assert (0);
- }
- }
+ check_fd (t, NULL != read_nh ? GNUNET_NETWORK_get_fd (read_nh) : -1);
+ check_fd (t, NULL != write_nh ? GNUNET_NETWORK_get_fd (write_nh) : -1);
+ check_fd (t, NULL != read_fh ? read_fh->fd : -1);
+ check_fd (t, NULL != write_fh ? write_fh->fd : -1);
#endif
#if PROFILE_DELAYS
t->start_time = GNUNET_TIME_absolute_get ();
@@ -1971,6 +1976,8 @@ select_loop (void *cls,
ws = GNUNET_NETWORK_fdset_create ();
last_tr = 0;
busy_wait_warning = 0;
+ // FIXME: remove check_lifeness, instead the condition should be:
+ // pending_in_head != NULL || pending_out_head != NULL || context->timeout > 0
while (GNUNET_YES == GNUNET_SCHEDULER_check_lifeness ())
{
GNUNET_NETWORK_fdset_zero (rs);
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] 07/45: make input of getters const (needed for new scheduler API), (continued)
- [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, 2017/12/30
- [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 <=
- [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
- [GNUnet-SVN] [gnunet] 34/45: cleanup, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 28/45: increasing length variable is already done by GNUNET_xgrow_ (called by the GNUNET_array_append macro), gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 31/45: improve documentation about the GNUNET_array_append and GNUNET_array_grow macros, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 22/45: Revert "set fds_len in all cases; call set_wakeup only in two places", gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 33/45: GNUNET_SCHEDULER_check_lifeness not needed anymore, gnunet, 2017/12/30
- [GNUnet-SVN] [gnunet] 23/45: set fds_len in all cases; call set_wakeup only in two places, gnunet, 2017/12/30