File 0012-io-make-use-of-poll-POLLERR-flag.patch of Package ruby2.5

From aa888d17f9a15ed86db13219446a6e31a1a12967 Mon Sep 17 00:00:00 2001
From: Michal Suchanek <msuchanek@suse.de>
Date: Mon, 3 Feb 2020 19:51:55 +0100
Subject: [PATCH 12/19] io: make use of poll POLLERR flag

Return additional array of fds with error.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 include/ruby/io.h | 2 ++
 thread.c          | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/include/ruby/io.h b/include/ruby/io.h
index 60d6f6d32ebb..11d2120e0ac8 100644
--- a/include/ruby/io.h
+++ b/include/ruby/io.h
@@ -43,10 +43,12 @@ extern "C" {
 #  define RB_WAITFD_IN  POLLIN
 #  define RB_WAITFD_PRI POLLPRI
 #  define RB_WAITFD_OUT POLLOUT
+#  define RB_WAITFD_ERR (POLLHUP|POLLERR)
 #else
 #  define RB_WAITFD_IN  0x001
 #  define RB_WAITFD_PRI 0x002
 #  define RB_WAITFD_OUT 0x004
+#  define RB_WAITFD_ERR 0x008
 #endif
 
 RUBY_SYMBOL_EXPORT_BEGIN
diff --git a/thread.c b/thread.c
index 980431236c92..95aacd2f5f13 100644
--- a/thread.c
+++ b/thread.c
@@ -4098,6 +4098,10 @@ rb_wait_for_single_fd(int fd, int events, struct timeval *tv)
     if (fds.revents & POLLEX_SET)
 	result |= RB_WAITFD_PRI;
 
+    /* all requested events are ready if there is an error */
+    if (fds.revents & POLLERR_SET)
+	result |= events | POLLERR_SET;
+
     return result;
 }
 #else /* ! USE_POLL - implement rb_io_poll_fd() using select() */
-- 
2.26.2

openSUSE Build Service is sponsored by