guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 09/58: 'select' returns empty sets upon EINTR and EAGAIN


From: Andy Wingo
Subject: [Guile-commits] 09/58: 'select' returns empty sets upon EINTR and EAGAIN.
Date: Tue, 7 Aug 2018 06:58:29 -0400 (EDT)

wingo pushed a commit to branch lightning
in repository guile.

commit 666f12c8714349ca791c361653ea9c492292d995
Author: Ludovic Court├Ęs <address@hidden>
Date:   Fri Feb 16 14:05:04 2018 +0100

    'select' returns empty sets upon EINTR and EAGAIN.
    
    Fixes <https://bugs.gnu.org/30368>.
    
    * libguile/filesys.c (scm_select): Clear READ_SET, WRITE_SET, and
    EXCEPT_SET when RV < 0.
---
 libguile/filesys.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/libguile/filesys.c b/libguile/filesys.c
index 0e4a0cf..7713c0a 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -906,10 +906,20 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0,
     int rv = scm_std_select (max_fd + 1,
                              &read_set, &write_set, &except_set,
                              time_ptr);
-    /* Let EINTR / EAGAIN cause a return to the user and let them loop
-       to run any asyncs that might be pending.  */
-    if (rv < 0 && errno != EINTR && errno != EAGAIN)
-      SCM_SYSERROR;
+    if (rv < 0)
+      {
+        /* Let EINTR / EAGAIN cause a return to the user and let them
+           loop to run any asyncs that might be pending.  */
+        if (errno != EINTR && errno != EAGAIN)
+          SCM_SYSERROR;
+        else
+          {
+            /* Return empty sets.  */
+            FD_ZERO (&read_set);
+            FD_ZERO (&write_set);
+            FD_ZERO (&except_set);
+          }
+      }
   }
 
   return scm_list_3 (retrieve_select_type (&read_set, read_ports_ready, reads),



reply via email to

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