diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-28 19:52:54 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-28 19:52:54 +0000 |
commit | 9c46ed792caae948fd99cca44deaf5a265af7614 (patch) | |
tree | f3e71b139a2cf4f40d27d500cb7b06f7192934bd /src/util | |
parent | 737e0d34d93673b98e5eb70be3456a7f87af71d3 (diff) | |
download | gnunet-9c46ed792caae948fd99cca44deaf5a265af7614.tar.gz gnunet-9c46ed792caae948fd99cca44deaf5a265af7614.zip |
-improved FD issue debug support
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/scheduler.c | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 57fbcf015..2f275b2df 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -589,7 +589,7 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, | |||
589 | unsigned int i; | 589 | unsigned int i; |
590 | 590 | ||
591 | for (i = 0; i < pos->num_backtrace_strings; i++) | 591 | for (i = 0; i < pos->num_backtrace_strings; i++) |
592 | LOG (GNUNET_ERROR_TYPE_ERROR, | 592 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
593 | "Task %p trace %u: %s\n", | 593 | "Task %p trace %u: %s\n", |
594 | pos, | 594 | pos, |
595 | i, | 595 | i, |
@@ -780,9 +780,16 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | |||
780 | timeout = GNUNET_TIME_UNIT_ZERO; | 780 | timeout = GNUNET_TIME_UNIT_ZERO; |
781 | } | 781 | } |
782 | if (NULL == scheduler_select) | 782 | if (NULL == scheduler_select) |
783 | ret = GNUNET_NETWORK_socket_select (rs, ws, NULL, timeout); | 783 | ret = GNUNET_NETWORK_socket_select (rs, |
784 | ws, | ||
785 | NULL, | ||
786 | timeout); | ||
784 | else | 787 | else |
785 | ret = scheduler_select (scheduler_select_cls, rs, ws, NULL, timeout); | 788 | ret = scheduler_select (scheduler_select_cls, |
789 | rs, | ||
790 | ws, | ||
791 | NULL, | ||
792 | timeout); | ||
786 | if (ret == GNUNET_SYSERR) | 793 | if (ret == GNUNET_SYSERR) |
787 | { | 794 | { |
788 | if (errno == EINTR) | 795 | if (errno == EINTR) |
@@ -801,9 +808,53 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task, | |||
801 | "system"); | 808 | "system"); |
802 | #endif | 809 | #endif |
803 | #endif | 810 | #endif |
811 | #if DEBUG_FDS | ||
812 | struct GNUNET_SCHEDULER_Task *t; | ||
813 | |||
814 | for (t = pending_head; NULL != t; t = t->next) | ||
815 | { | ||
816 | if (-1 != t->read_fd) | ||
817 | { | ||
818 | int flags = fcntl (t->read_fd, F_GETFD); | ||
819 | if ((flags == -1) && (errno == EBADF)) | ||
820 | { | ||
821 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
822 | "Got invalid file descriptor %d!\n", | ||
823 | t->read_fd); | ||
824 | #if EXECINFO | ||
825 | unsigned int i; | ||
826 | |||
827 | for (i = 0; i < t->num_backtrace_strings; i++) | ||
828 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
829 | "Trace: %s\n", | ||
830 | t->backtrace_strings[i]); | ||
831 | #endif | ||
832 | } | ||
833 | } | ||
834 | if (-1 != t->write_fd) | ||
835 | { | ||
836 | int flags = fcntl (t->write_fd, F_GETFD); | ||
837 | if ((flags == -1) && (errno == EBADF)) | ||
838 | { | ||
839 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
840 | "Got invalid file descriptor %d!\n", | ||
841 | t->write_fd); | ||
842 | #if EXECINFO | ||
843 | unsigned int i; | ||
844 | |||
845 | for (i = 0; i < t->num_backtrace_strings; i++) | ||
846 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
847 | "Trace: %s\n", | ||
848 | t->backtrace_strings[i]); | ||
849 | #endif | ||
850 | } | ||
851 | } | ||
852 | } | ||
853 | #endif | ||
804 | GNUNET_assert (0); | 854 | GNUNET_assert (0); |
805 | break; | 855 | break; |
806 | } | 856 | } |
857 | |||
807 | if ( (0 == ret) && | 858 | if ( (0 == ret) && |
808 | (0 == timeout.rel_value_us) && | 859 | (0 == timeout.rel_value_us) && |
809 | (busy_wait_warning > 16) ) | 860 | (busy_wait_warning > 16) ) |
@@ -1260,10 +1311,10 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1260 | "Got invalid file descriptor %d!\n", | 1311 | "Got invalid file descriptor %d!\n", |
1261 | rfd); | 1312 | rfd); |
1262 | #if EXECINFO | 1313 | #if EXECINFO |
1263 | int i; | 1314 | unsigned int i; |
1264 | 1315 | ||
1265 | for (i = 0; i < t->num_backtrace_strings; i++) | 1316 | for (i = 0; i < t->num_backtrace_strings; i++) |
1266 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1317 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1267 | "Trace: %s\n", | 1318 | "Trace: %s\n", |
1268 | t->backtrace_strings[i]); | 1319 | t->backtrace_strings[i]); |
1269 | #endif | 1320 | #endif |
@@ -1280,7 +1331,7 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1280 | "Got invalid file descriptor %d!\n", | 1331 | "Got invalid file descriptor %d!\n", |
1281 | wfd); | 1332 | wfd); |
1282 | #if EXECINFO | 1333 | #if EXECINFO |
1283 | int i; | 1334 | unsigned int i; |
1284 | 1335 | ||
1285 | for (i = 0; i < t->num_backtrace_strings; i++) | 1336 | for (i = 0; i < t->num_backtrace_strings; i++) |
1286 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1337 | LOG (GNUNET_ERROR_TYPE_DEBUG, |