guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 02/03: scm_std_select doesn't tick itself


From: Andy Wingo
Subject: [Guile-commits] 02/03: scm_std_select doesn't tick itself
Date: Wed, 1 Mar 2017 11:28:17 -0500 (EST)

wingo pushed a commit to branch master
in repository guile.

commit 0660364998a5d6492858cd7270e7e7349521711d
Author: Andy Wingo <address@hidden>
Date:   Wed Mar 1 17:23:48 2017 +0100

    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.
---
 libguile/threads.c | 61 +++++++++++++++++++++++++++++-------------------------
 1 file changed, 33 insertions(+), 28 deletions(-)

diff --git a/libguile/threads.c b/libguile/threads.c
index e67616c..c999411 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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]