1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

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.
This commit is contained in:
Andy Wingo 2017-03-01 17:23:48 +01:00
parent 0cd60c3f26
commit 0660364998

View file

@ -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;
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);
res = args.result;
eno = args.errno_value;
scm_i_wait_finished (t);
if (res > 0 && FD_ISSET (wakeup_fd, readfds))
if (scm_i_prepare_to_wait_on_fd (t, t->sleep_pipe[1]))
{
char dummy;
full_read (wakeup_fd, &dummy, 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;
FD_CLR (wakeup_fd, readfds);
res -= 1;
if (res == 0)
{
eno = EINTR;
res = -1;
}
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);
res = args.result;
eno = args.errno_value;
scm_i_wait_finished (t);
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;
}
}
}
errno = eno;
return res;