From: Alex Young Date: 2011-02-10T20:59:27+09:00 Subject: What should TCPSocket#close do to a blocked #readline? Take the following code: require 'socket' require 'thread' server = TCPServer.new("localhost", 0) serv_thread = Thread.new{ server.accept } sleep(0.1) sock = TCPSocket.new("localhost", server.addr[1]) q = Queue.new client_thread = Thread.new{ begin sock.readline rescue StandardError => e q.push(e) end } sleep(0.1) while client_thread.status == "run" sock.close # client_thread.wakeup rescue nil err = q.pop client_thread.join fail "Failure!" unless err.is_a?(IOError) puts "Success!" So, we've got one thread blocked on a #readline, and another thread closes the socket out from under it. On 1.8.7-p302, this completes successfully. On 1.9.2-p136, it hangs at q.pop. If I uncomment the client_thread.wakeup call, both complete (although the rescue is necessary to prevent a ThreadError on 1.8.7). Is this expected? Which is "correct"? Thanks, -- Alex -- Posted via http://www.ruby-forum.com/.