about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-03-09 04:35:18 +0000
committerEric Wong <e@80x24.org>2015-03-09 04:35:18 +0000
commite413325737f23c5ec27a02246f95077bc1fb038d (patch)
treecff1568e5326cde3921b84531702aca8eb3d679c /lib
parent94538f003c4031f33eb6545032bd234e483e65c6 (diff)
downloadyahns-e413325737f23c5ec27a02246f95077bc1fb038d.tar.gz
When inheriting sockets from the parent via YAHNS_FD, we must close
sockets ASAP if they are unconfigured in the child.  This bug exists
in yahns (and not unicorn) because of the trickier shutdown routine
we do for blocking accept system calls to work reliably with the
threading support in mainline Ruby 2.x.  This bug would not exist
in a purely C server using blocking accept, either.
Diffstat (limited to 'lib')
-rw-r--r--lib/yahns/acceptor.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/yahns/acceptor.rb b/lib/yahns/acceptor.rb
index cd9e055..0cebea2 100644
--- a/lib/yahns/acceptor.rb
+++ b/lib/yahns/acceptor.rb
@@ -19,7 +19,10 @@ module Yahns::Acceptor # :nodoc:
 
   # just keep looping this on every acceptor until the associated thread dies
   def ac_quit
-    return true unless defined?(@thrs)
+    unless defined?(@thrs) # acceptor has not started yet, freshly inherited
+      close
+      return true
+    end
     @thrs.each { |t| t[:yahns_quit] = true }
     return true if __ac_quit_done?