Skip Menu |

This queue is for tickets about the Net-SIP CPAN distribution.

Report information
The Basics
Id: 122526
Status: rejected
Priority: 0/
Queue: Net-SIP

People
Owner: Nobody in particular
Requestors: richard.carver [...] cloudmont.co.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: SocketPool loses track of IPv6 TLS socket
Date: Mon, 17 Jul 2017 15:39:53 +0000
To: "bug-Net-SIP [...] rt.cpan.org" <bug-Net-SIP [...] rt.cpan.org>
From: Richard Carver <richard.carver [...] cloudmont.co.uk>
When a remote server connects into mine (Net::SIP::StatelessProxy on CentOS 7) using IPv6 and TLS. SIP messages are exchanged successfully, and after a while Net::SIP::SocketPool runs _timeout_sockets and it decides to delete this socket. The problem is that the socket does not get closed, so when the next call is made the remote server re-uses the connection and it is ignored by my application. I can see this using 'netstat -W -6' and noting that the socket is still established and the read buffer is non-zero and stays that way. I added debug to the module and have found that the reference count to the IO::Socket::SSL object that is being deleted in _timeout_sockets is one more than it should be when it is removed from the socketpool hash. The socket is not explicitly closed and relies on DESTROY being called to do this. Due to the reference count still being 1 DESTROY is not called so the socket is not closed. This appears to be limited to IPv6 as the reference count for IPv4 connections is correct. All of my connections use TLS, so I cannot say whether it occurs without TLS. I have been unable to find where the extra reference is being stored, but note that adding this line to the end of Net::SIP::SocketPool::_del_socket resolves the main issue: $fo->{fd}->close; I do not propose this as a permanent solution as the socket objects are probably not being freed from memory.
Am Di 18. Jul 2017, 00:13:09, richard.carver@cloudmont.co.uk schrieb: Show quoted text
> When a remote server connects into mine (Net::SIP::StatelessProxy on > CentOS 7) using IPv6 and TLS. SIP messages are exchanged successfully, > and after a while Net::SIP::SocketPool runs _timeout_sockets and it > decides to delete this socket. The problem is that the socket does not > get closed, so when the next call is made the remote server re-uses > the connection and it is ignored by my application. I can see this > using 'netstat -W -6' and noting that the socket is still established > and the read buffer is non-zero and stays that way.
Thanks for reporting the problem. There is no special handling of IPv6 vs. IPv4 sockets in Net::SIP. Socket creating is done with Net::SIP::Util::INETSOCK which uses the same socket class for all, i.e. preferred IO::Socket::IP. If this is not available IO::Socket::INET6 and as the last resort IO::Socket::INET (no IPv6 support in this case). There is also no special IPv6 handling done in IO::Socket::SSL. From this I would conclude that the reported problem is due to a special handling of IPv6 outside of Net::SIP, i.e. either in your code or in IO::Socket::IP. Given that CentOS 7 comes with an older version of IO::Socket::IP (0.21 vs. 0.39) I would try to upgrade this first. If this does not resolve the problem please provide a minimal test case so that I could reproduce the problem myself.
Subject: RE: [rt.cpan.org #122526] SocketPool loses track of IPv6 TLS socket
Date: Thu, 16 Nov 2017 17:55:57 +0000
To: "bug-Net-SIP [...] rt.cpan.org" <bug-Net-SIP [...] rt.cpan.org>
From: Richard Carver <richard.carver [...] cloudmont.co.uk>
Thanks for the analysis - I think you are right. I can confirm that I am unable to reproduce the problem on IO::Socket::IP 0.39.