Backport #2726

udp socket send and receive leak handles on windows

Added by John Stewart about 2 years ago. Updated 10 months ago.

[ruby-core:28118]
Status:Open Start date:02/09/2010
Priority:High Due date:
Assignee:- % Done:

0%

Category:-
Target version:-

Description

UDP receiver:
require 'socket'

dis_socket = Socket.new( Socket::AF_INET, Socket::SOCK_DGRAM, 0 )
dis_socket.bind(Socket.pack_sockaddr_in( 3000, INADDR_ANY ))

while 1
    text, sender = dis_socket.recvfrom(65536)
end

UDP sender:
require 'socket'

dis_socket = UDPSocket.open
while 1
    dis_socket.send("0123456789", 0, "localhost", 3000)
end

Run one instance of each of the above.  Bring up the task manager, add the Handles column, and watch both processes leak handles like a sieve.  They appear to leak 1 handle per recvfrom/send call. 

The handle count stops around 650k, with seemingly no ill effect.  But in more complex programs, file i/o methods start throwing Errno::EBADF exceptions at about the same time the handle count peaks.

Under 1.8.6, the same programs do not leak any handles.

On the possibility it's OS specific, I'm observing the handle leaks on a machine running 64-bit Windows Vista.

It's likely this issue is related to issue #2473.

History

Updated by Roger Pack about 2 years ago

appears fixed in ruby 1.9.2dev (2010-02-08 trunk 26621) [i386-mingw32]

Also your snippet requires Socket::INADDR_ANY :)
-r

Also available in: Atom PDF