google-code-export / rtmplite

Automatically exported from code.google.com/p/rtmplite
3 stars 1 forks source link

List of sockets for RTP/RTCP keeps growing with every call. #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Reported by Franck <infos@madovsky.org> on Jan 28, 2011
Fixed in p2p-sip's svn r26 (version 1.10)

Hi Kundan,

didn't have any news from you.
hope you're well.

after experiment with rfc3550
I noticed that with p2p and siprtmp
udp socket session still stays open undiefinetly
and the list of socket is growing after every call.
so despite of my bad knowledge in python
i got the trick below:

    def close(self):
        if _debug: print 'cleaning up sockets'
        if self.rtp: self.rtp.close(); self.rtp = None
        if self.rtcp: self.rtcp.close(); self.rtcp = None
        if self.app: self.app = None
        self = None
once the call hangup siprtmp clean completely the ocket
and avoid that all udp port raange to be reached.

Take care

---
Hi Franck,

I think I found the problem.
It was a terrible oversight on my part in rfc3550.py.
I have fixed it in svn r26 as shown in
http://code.google.com/p/p2p-sip/source/list

I have also attached rfc3550.py which you can use to replace yours in
p2p-sip/src/std/rfc3550.py

Thanks a lot for helping with this bug!

Original issue reported on code.google.com by voiprese...@gmail.com on 7 Feb 2011 at 4:43

GoogleCodeExporter commented 9 years ago

Original comment by voiprese...@gmail.com on 7 Feb 2011 at 4:44

GoogleCodeExporter commented 9 years ago
Hmmm... this fix does not really fix the problem completely.

The OS command (on Mac: sudo lsof -i -P | grep -i Python) still shows that the 
sockets are not freed for RTP/RTCP.

It seems like multitask.py related issue. If I replace both multitask.recvfrom 
related code (and next line) from receiveRTP and receiveRTCP with 
multitask.sleep(0.05), then it can work in cleaning up the sockets. So looks 
like if multitask gets hold of the socket, it never gets freed easily. I 
checked that all open sockets are calling close() correctly, but still the OS 
shows them as not closed.

Original comment by voiprese...@gmail.com on 7 Feb 2011 at 4:46

GoogleCodeExporter commented 9 years ago
Fixed in rtmplite svn r43 and p2p-sip svn r27

In std/rfc3550.py cleanup rtp/rtcp socket by explicitly closing file descriptor.
In multitask.py do not enqueue exception when removing bad descriptors.

The problem was that once an UDP socket goes to multitask.recvfrom, it never 
gets closed unless you explicitly close the underlying file descriptor using 
os.close(sock.fileno()). BUT. sock.fileno() becomes invalid after sock.close(). 
AND. multitask throws an exception if underlying file descriptor is closed. The 
fix changes multitask to not throw that exception when removing bad file 
descriptors. And changes RTP rfc3550.py to close underlying file descriptor 
after the receiving tasks terminate.

Original comment by voiprese...@gmail.com on 8 Feb 2011 at 6:47

GoogleCodeExporter commented 9 years ago
The attached file shows the problem and the solution.

If you comment out os.close(fn) then on Mac OS X your command
$ sudo lsof -i -P | grep -i Python
will show the open socket port even after it is closed using s.close().
With os.close(fn), the command does not show open socket port any more.

Original comment by voiprese...@gmail.com on 8 Feb 2011 at 6:50

Attachments: