Skip to content

Commit

Permalink
Be sure not to close the socket before the Errno.handle call
Browse files Browse the repository at this point in the history
Also a small fix for a spec that fails on OpenBSD
  • Loading branch information
dbussink committed Mar 10, 2008
1 parent be5b11c commit 25e3f23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/socket.rb
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions spec/ruby/1.8/library/socket/tcpsocket/new_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 25e3f23

Please sign in to comment.