Project

General

Profile

Actions

Backport #4132

closed

Socket.close attempting to close the socket twice

Added by devmod (Claudio Villalobos) over 13 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
[ruby-core:33628]

Description

=begin
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);
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0