From e83756512c44294137ee3362cf131eed70663fb1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 9 Apr 2009 23:09:03 -0700 Subject: close listeners when removing them from our array This fixes a long-standing bug where listeners would be removed from the known listener set during a reload but never correctly shut down (until reexec). Additionally, test_server was working around this bug (my fault, subconciously) as teardown did not unbind the socket, requiring the tests to grab a new port. --- lib/unicorn.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/unicorn.rb b/lib/unicorn.rb index f8e0a5d..6b50319 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -110,8 +110,10 @@ module Unicorn @listeners.delete_if do |io| if dead_names.include?(sock_name(io)) - @io_purgatory.delete_if { |pio| pio.fileno == io.fileno } - true + @io_purgatory.delete_if do |pio| + pio.fileno == io.fileno && (pio.close rescue nil).nil? + end + (io.close rescue nil).nil? else false end -- cgit v1.2.3-24-ge0c7