aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlurchi <lurchi@strangeplace.net>2017-08-10 20:05:37 +0200
committerlurchi <lurchi@strangeplace.net>2017-08-10 20:05:37 +0200
commit4e82b4961abb33ccacf95fa7b3101450230bf10d (patch)
treec302f7d0d2b5b4bea638f09034c1047cdc641ee0 /src
parent6fcafa3adc10394ad79db171a3a22c3260512f43 (diff)
downloadgnunet-4e82b4961abb33ccacf95fa7b3101450230bf10d.tar.gz
gnunet-4e82b4961abb33ccacf95fa7b3101450230bf10d.zip
fix compilation of debug code enabled by DEBUG_FDS; fix indentation
Diffstat (limited to 'src')
-rw-r--r--src/util/scheduler.c63
1 files 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,
1073struct GNUNET_SCHEDULER_Task * 1073struct GNUNET_SCHEDULER_Task *
1074GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay, 1074GNUNET_SCHEDULER_add_delayed (struct GNUNET_TIME_Relative delay,
1075 GNUNET_SCHEDULER_TaskCallback task, 1075 GNUNET_SCHEDULER_TaskCallback task,
1076 void *task_cls) 1076 void *task_cls)
1077{ 1077{
1078 return GNUNET_SCHEDULER_add_delayed_with_priority (delay, 1078 return GNUNET_SCHEDULER_add_delayed_with_priority (delay,
1079 GNUNET_SCHEDULER_PRIORITY_DEFAULT, 1079 GNUNET_SCHEDULER_PRIORITY_DEFAULT,
1080 task, 1080 task,
1081 task_cls); 1081 task_cls);
1082} 1082}
1083 1083
1084 1084
@@ -1175,6 +1175,33 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness,
1175} 1175}
1176 1176
1177 1177
1178#if DEBUG_FDS
1179/**
1180 * check a raw file descriptor and abort if it is bad (for debugging purposes)
1181 *
1182 * @param t the task related to the file descriptor
1183 * @param raw_fd the raw file descriptor to check
1184 */
1185void
1186check_fd (struct GNUNET_SCHEDULER_Task *t, int raw_fd)
1187{
1188 if (-1 != raw_fd)
1189 {
1190 int flags = fcntl (raw_fd, F_GETFD);
1191
1192 if ((flags == -1) && (errno == EBADF))
1193 {
1194 LOG (GNUNET_ERROR_TYPE_ERROR,
1195 "Got invalid file descriptor %d!\n",
1196 raw_fd);
1197 init_backtrace (t);
1198 GNUNET_assert (0);
1199 }
1200 }
1201}
1202#endif
1203
1204
1178/** 1205/**
1179 * Schedule a new task to be run with a specified delay or when any of 1206 * Schedule a new task to be run with a specified delay or when any of
1180 * the specified file descriptor sets is ready. The delay can be used 1207 * the specified file descriptor sets is ready. The delay can be used
@@ -1220,32 +1247,10 @@ add_without_sets (struct GNUNET_TIME_Relative delay,
1220 t->callback = task; 1247 t->callback = task;
1221 t->callback_cls = task_cls; 1248 t->callback_cls = task_cls;
1222#if DEBUG_FDS 1249#if DEBUG_FDS
1223 if (-1 != rfd) 1250 check_fd (t, NULL != read_nh ? GNUNET_NETWORK_get_fd (read_nh) : -1);
1224 { 1251 check_fd (t, NULL != write_nh ? GNUNET_NETWORK_get_fd (write_nh) : -1);
1225 int flags = fcntl (rfd, F_GETFD); 1252 check_fd (t, NULL != read_fh ? read_fh->fd : -1);
1226 1253 check_fd (t, NULL != write_fh ? write_fh->fd : -1);
1227 if ((flags == -1) && (errno == EBADF))
1228 {
1229 LOG (GNUNET_ERROR_TYPE_ERROR,
1230 "Got invalid file descriptor %d!\n",
1231 rfd);
1232 init_backtrace (t);
1233 GNUNET_assert (0);
1234 }
1235 }
1236 if (-1 != wfd)
1237 {
1238 int flags = fcntl (wfd, F_GETFD);
1239
1240 if (flags == -1 && errno == EBADF)
1241 {
1242 LOG (GNUNET_ERROR_TYPE_ERROR,
1243 "Got invalid file descriptor %d!\n",
1244 wfd);
1245 init_backtrace (t);
1246 GNUNET_assert (0);
1247 }
1248 }
1249#endif 1254#endif
1250#if PROFILE_DELAYS 1255#if PROFILE_DELAYS
1251 t->start_time = GNUNET_TIME_absolute_get (); 1256 t->start_time = GNUNET_TIME_absolute_get ();
@@ -1971,6 +1976,8 @@ select_loop (void *cls,
1971 ws = GNUNET_NETWORK_fdset_create (); 1976 ws = GNUNET_NETWORK_fdset_create ();
1972 last_tr = 0; 1977 last_tr = 0;
1973 busy_wait_warning = 0; 1978 busy_wait_warning = 0;
1979 // FIXME: remove check_lifeness, instead the condition should be:
1980 // pending_in_head != NULL || pending_out_head != NULL || context->timeout > 0
1974 while (GNUNET_YES == GNUNET_SCHEDULER_check_lifeness ()) 1981 while (GNUNET_YES == GNUNET_SCHEDULER_check_lifeness ())
1975 { 1982 {
1976 GNUNET_NETWORK_fdset_zero (rs); 1983 GNUNET_NETWORK_fdset_zero (rs);