Bug #4132: Socket.close attempting to close the socket twice
http://redmine.ruby-lang.org/issues/show/4132

Author: Claudio Villalobos
Status: Open, Priority: Normal
Category: ext
ruby -v: ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]

Socket.close calls shutdown twice on the same file descriptor 

## socktest.rb ##
require 'socket'
include Socket::Constants
socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
socket.bind( sockaddr )
socket.listen( 5 )
puts "socket.to_i: #{socket.to_i}"
socket.close
#############

$ strace -e trace=open,close ruby1.8 socktest.rb
...
socket.to_i: 3
close(3)                                = 0
close(3)                                = -1 EBADF (Bad file descriptor)

-------------
socket.c
-
socks_s_close(sock)
...
1386	shutdown(fileno(fptr->f), 2);
1387	shutdown(fileno(fptr->f2), 2);


----------------------------------------
http://redmine.ruby-lang.org