summaryrefslogtreecommitdiff
path: root/libguile/threads.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-03-01 17:23:48 +0100
committerAndy Wingo <wingo@pobox.com>2017-03-01 17:23:48 +0100
commit0660364998a5d6492858cd7270e7e7349521711d (patch)
tree172254f1a3bd312327010f14acab6f42f5f1945f /libguile/threads.c
parent0cd60c3f2660f6fe08845a4bc1836ac8e933e9e6 (diff)
downloadguile-0660364998a5d6492858cd7270e7e7349521711d.tar.gz
scm_std_select doesn't tick itself
* libguile/threads.c (scm_std_select): If there are unblocked asyncs pending, return directly instead of ticking ourselves.
Diffstat (limited to 'libguile/threads.c')
-rw-r--r--libguile/threads.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/libguile/threads.c b/libguile/threads.c
index e67616c03..c999411e1 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -1539,40 +1539,45 @@ scm_std_select (int nfds,
readfds = &my_readfds;
}
- while (scm_i_prepare_to_wait_on_fd (t, t->sleep_pipe[1]))
- SCM_TICK;
-
- wakeup_fd = t->sleep_pipe[0];
- FD_SET (wakeup_fd, readfds);
- if (wakeup_fd >= nfds)
- nfds = wakeup_fd+1;
+ if (scm_i_prepare_to_wait_on_fd (t, t->sleep_pipe[1]))
+ {
+ eno = EINTR;
+ res = -1;
+ }
+ else
+ {
+ wakeup_fd = t->sleep_pipe[0];
+ FD_SET (wakeup_fd, readfds);
+ if (wakeup_fd >= nfds)
+ nfds = wakeup_fd+1;
- args.nfds = nfds;
- args.read_fds = readfds;
- args.write_fds = writefds;
- args.except_fds = exceptfds;
- args.timeout = timeout;
+ args.nfds = nfds;
+ args.read_fds = readfds;
+ args.write_fds = writefds;
+ args.except_fds = exceptfds;
+ args.timeout = timeout;
- /* Explicitly cooperate with the GC. */
- scm_without_guile (do_std_select, &args);
+ /* Explicitly cooperate with the GC. */
+ scm_without_guile (do_std_select, &args);
- res = args.result;
- eno = args.errno_value;
+ res = args.result;
+ eno = args.errno_value;
- scm_i_wait_finished (t);
+ scm_i_wait_finished (t);
- if (res > 0 && FD_ISSET (wakeup_fd, readfds))
- {
- char dummy;
- full_read (wakeup_fd, &dummy, 1);
+ if (res > 0 && FD_ISSET (wakeup_fd, readfds))
+ {
+ char dummy;
+ full_read (wakeup_fd, &dummy, 1);
- FD_CLR (wakeup_fd, readfds);
- res -= 1;
- if (res == 0)
- {
- eno = EINTR;
- res = -1;
- }
+ FD_CLR (wakeup_fd, readfds);
+ res -= 1;
+ if (res == 0)
+ {
+ eno = EINTR;
+ res = -1;
+ }
+ }
}
errno = eno;
return res;