diff options
| -rw-r--r-- | CHANGELOG.rdoc | 5 | ||||
| -rw-r--r-- | lib/net/ssh/transport/packet_stream.rb | 15 |
2 files changed, 17 insertions, 3 deletions
diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index 4175f6a..e7cc6d6 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -1,5 +1,10 @@ +=== 2.0.14 / ?? Aug 2009 + +* Fix for IO#select threading bug in Ruby 1.8 (LH-1) [Daniel Azuma] + + === 2.0.13 / 17 Aug 2009 * Added fix for hanging in ServerVersion#negotiate! when using SOCKS5 proxy (GH-9) [Gerald Talton] diff --git a/lib/net/ssh/transport/packet_stream.rb b/lib/net/ssh/transport/packet_stream.rb index 07bee62..ff758a0 100644 --- a/lib/net/ssh/transport/packet_stream.rb +++ b/lib/net/ssh/transport/packet_stream.rb @@ -5,6 +5,8 @@ require 'net/ssh/transport/cipher_factory' require 'net/ssh/transport/hmac' require 'net/ssh/transport/state' +require 'thread' + module Net; module SSH; module Transport # A module that builds additional functionality onto the Net::SSH::BufferedIo @@ -62,13 +64,20 @@ module Net; module SSH; module Transport Socket.getnameinfo(addr, Socket::NI_NUMERICHOST | Socket::NI_NUMERICSERV).first end end - + + # A fix for an IO#select threading bug + # See: http://www.daniel-azuma.com/blog/view/z2ysbx0e4c3it9/ruby_1_8_7_io_select_threading_bug + MUTEX = Mutex.new + # Returns true if the IO is available for reading, and false otherwise. def available_for_read? - result = IO.select([self], nil, nil, 0) + result = nil + MUTEX.synchronize do + result = IO.select([self], nil, nil, 0) + end result && result.first.any? end - + # Returns the next full packet. If the mode parameter is :nonblock (the # default), then this will return immediately, whether a packet is # available or not, and will return nil if there is no packet ready to be |
