Permalink
Browse files

Be sure not to close the socket before the Errno.handle call

Also a small fix for a spec that fails on OpenBSD
  • Loading branch information...
1 parent be5b11c commit 25e3f23e78f2b17e02d2c0a058925f8a0ec0d790 @dbussink dbussink committed Mar 10, 2008
Showing with 7 additions and 4 deletions.
  1. +3 −2 lib/socket.rb
  2. +4 −2 spec/ruby/1.8/library/socket/tcpsocket/new_spec.rb
View
@@ -632,11 +632,12 @@ def tcp_setup(remote_host, remote_service, local_host = nil,
end
break if status >= 0
+ end
+ if status < 0
+ Errno.handle syscall
Socket::Foreign.close descriptor
end
-
- Errno.handle if status < 0
if server then
err = Socket::Foreign.listen descriptor, 5
@@ -32,8 +32,10 @@
sock.addr[0].should == "AF_INET"
sock.addr[1].should be_kind_of Fixnum
# on some platforms (Mac), MRI
- # returns comma at the end.
- sock.addr[2].should =~ /^localhost,?$/
+ # returns comma at the end. Other
+ # platforms such as OpenBSD setup the
+ # localhost as localhost.domain.com
+ sock.addr[2].should =~ /^localhost/
sock.addr[3].should == "127.0.0.1"
thread.join
end

0 comments on commit 25e3f23

Please sign in to comment.