Bug 45279

Summary: McastServiceImpl leaks sockets.
Product: Tomcat 6 Reporter: Robert Newson <robert.newson>
Component: ClusterAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 6.0.16   
Target Milestone: default   
Hardware: PC   
OS: Linux   

Description Robert Newson 2008-06-25 12:21:15 UTC
McastServiceImpl does not close its socket in stop() as it claims. It merely calls leaveGroup(), which is sufficient to stop receiving messages, but does not close the socket. 

This causes a file descriptor leak each time the service is stopped.

add;

socket.close();

after leaveGroup();
Comment 1 Robert Newson 2008-06-25 13:13:34 UTC
btw, since it unreferences the socket without closing it, the next start() makes a new socket anyway.

I've hacked around this by using reflection to grab the reference to the multicast socket object before calling stop, then calling stop, then closing the socket myself.

Comment 2 Filip Hanik 2008-06-25 13:48:05 UTC
Fix suggested for back port into 6.0 branch
Comment 3 Filip Hanik 2008-06-30 13:03:21 UTC
Fixed in 6.0.x branch, will be included in 6.0.17 and forward

Comment 4 Rainer Jung 2009-07-01 12:31:52 UTC
Also applied to TC 5.5 as r790337.
Will be part of 5.5.28.