about summary refs log tree commit homepage
path: root/lib/rainbows.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rainbows.rb')
-rw-r--r--lib/rainbows.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/rainbows.rb b/lib/rainbows.rb
index d3a3e7d..9260649 100644
--- a/lib/rainbows.rb
+++ b/lib/rainbows.rb
@@ -60,6 +60,13 @@ module Rainbows
 
     # returns nil if accept fails
     if defined?(Fcntl::FD_CLOEXEC)
+      def sync_accept(sock)
+        rv = sock.accept
+        rv.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
+        rv
+      rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EINTR
+      end
+
       def accept(sock)
         rv = sock.accept_nonblock
         rv.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
@@ -67,6 +74,11 @@ module Rainbows
       rescue Errno::EAGAIN, Errno::ECONNABORTED
       end
     else
+      def sync_accept(sock)
+        sock.accept
+      rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EINTR
+      end
+
       def accept(sock)
         sock.accept_nonblock
       rescue Errno::EAGAIN, Errno::ECONNABORTED