After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 622757 - gst-rtsp-server needs the SO_LINGER option to be set to reset the TCP connection immediately for port reuse
gst-rtsp-server needs the SO_LINGER option to be set to reset the TCP connect...
Status: RESOLVED WONTFIX
Product: GStreamer
Classification: Platform
Component: gst-rtsp-server
0.10.5
Other Linux
: Normal normal
: 0.10.6
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-06-25 18:49 UTC by Robert Krakora
Modified: 2010-08-20 14:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to set NO_LINGER option on RTSP TCP Sockets to allow immediate reuse of address/port combinations (850 bytes, patch)
2010-07-07 16:48 UTC, Robert Krakora
none Details | Review
Patch to set NO_LINGER option on RTSP TCP Sockets to allow immediate reuse of address/port combinations with new multicast address specification property (5.24 KB, patch)
2010-07-07 16:54 UTC, Robert Krakora
none Details | Review
Patch to set NO_LINGER option on RTSP TCP Sockets to allow immediate reuse of address/port combinations with new multicast address specification property take 2... (8.18 KB, patch)
2010-07-07 17:00 UTC, Robert Krakora
none Details | Review

Description Robert Krakora 2010-06-25 18:49:21 UTC
I think gst-rtsp-server needs the SO_LINGER option to be set to reset
the TCP connection immediately.

 linger.l_onoff = 1;
 linger.l_linger = 0;

 if (setsockopt (server->server_sock.fd, SOL_SOCKET, SO_LINGER,
         (void *) &linger, sizeof (linger)) < 0)
   goto linger_failed;
Comment 1 Wim Taymans 2010-06-29 08:54:36 UTC
care to make a patch?
Comment 2 Robert Krakora 2010-06-29 16:33:21 UTC
Wim,

I can make a patch; against the tip?

Best Regards,

Rob Krakora
Comment 3 Robert Krakora 2010-07-07 16:46:39 UTC
Attached is the patch.  It actually needed to be make to gstrtspconnection.c in gst-plugins-base.
Comment 4 Robert Krakora 2010-07-07 16:48:39 UTC
Created attachment 165427 [details] [review]
Patch to set NO_LINGER option on RTSP TCP Sockets to allow immediate reuse of address/port combinations

Here is the patch.
Comment 5 Robert Krakora 2010-07-07 16:54:38 UTC
Created attachment 165428 [details] [review]
Patch to set NO_LINGER option on RTSP TCP Sockets to allow immediate reuse of address/port combinations with new multicast address specification property

Sent the wrong patch initially...here is the correct one...
Comment 6 Robert Krakora 2010-07-07 17:00:49 UTC
Created attachment 165429 [details] [review]
Patch to set NO_LINGER option on RTSP TCP Sockets to allow immediate reuse of address/port combinations with new multicast address specification property take 2...

O.K., here is the final patch...it adds NO LINGER and settable multicast address property with default if not specified...
Comment 7 Wim Taymans 2010-08-16 10:47:51 UTC
Commited the SO_LINGER part. I believe the configuration of the multicast address should be done on the media-factory. This would make it possible to have one server send on multiple multicast addresses depending on the media.


commit 8f6fd320654f5390d72027ac289921f1f26e40b4
Author: Robert Krakora <rob.krakora at messagenetsystems.com>
Date:   Mon Aug 16 12:32:28 2010 +0200

    server: use SO_LINGER
    
    SO_LINGER on the socket will make sure that any pending data on the socket is
    flushed ASAP and that the socket connection is reset. This makes sure that the
    socket can be reused immediately.
    
    Fixes 622757
Comment 8 Robert Krakora 2010-08-16 11:40:42 UTC
(In reply to comment #7)
> Commited the SO_LINGER part. I believe the configuration of the multicast
> address should be done on the media-factory. This would make it possible to
> have one server send on multiple multicast addresses depending on the media.
> 
> 
> commit 8f6fd320654f5390d72027ac289921f1f26e40b4
> Author: Robert Krakora <rob.krakora at messagenetsystems.com>
> Date:   Mon Aug 16 12:32:28 2010 +0200
> 
>     server: use SO_LINGER
> 
>     SO_LINGER on the socket will make sure that any pending data on the socket
> is
>     flushed ASAP and that the socket connection is reset. This makes sure that
> the
>     socket can be reused immediately.
> 
>     Fixes 622757

Wim,

I agree that the multicast address should be done on the media-factory.  Will this be a change that you will be making for an upcoming release or would you like me to take a stab at it and submit it to you for comments/suggestions/rework?

Best Regards,

Rob Krakora
Comment 9 Wim Taymans 2010-08-16 11:51:22 UTC
(In reply to comment #8)
> I agree that the multicast address should be done on the media-factory.  

I think it should even be done on the rtsp-media level, on second thoughts. This would then be similar to where you would configure the allowed protocols for a media resource.

> Will
> this be a change that you will be making for an upcoming release or would you
> like me to take a stab at it and submit it to you for
> comments/suggestions/rework?

I don't plan on doing that myself, so patches are welcome.
Comment 10 Robert Krakora 2010-08-16 12:08:58 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > I agree that the multicast address should be done on the media-factory.  
> 
> I think it should even be done on the rtsp-media level, on second thoughts.
> This would then be similar to where you would configure the allowed protocols
> for a media resource.
> 
> > Will
> > this be a change that you will be making for an upcoming release or would you
> > like me to take a stab at it and submit it to you for
> > comments/suggestions/rework?
> 
> I don't plan on doing that myself, so patches are welcome.

Wim,

I can work on this.  I will submit a patch when it is complete.  Would you like me to open a separate ticket for it?

Best Regards,

Rob Krakora
Comment 11 Wim Taymans 2010-08-19 16:52:02 UTC
The SO_LINGER patch doesn't work so well after all. 

The problem is that right after the TEARDOWN reply has been sent to the client, the connection is closed. Because SO_LINGER is now off, it discards any data that might still be in the send buffers and sends a RST to the client. This sometimes causes the client to fail to read the reply of the TEARDOWN.

I also tried to set the linger parameter to something else than 0, which causes the TCP stack to wait for this amount of seconds before clearing and reseting the connection. With a 5 second linger, this made things work again.

Also, SO_LINGER doesn't seem to be well supported/implemented on all platforms.

I'm considering revering the patch...
Comment 12 Robert Krakora 2010-08-19 17:21:15 UTC
(In reply to comment #11)
> The SO_LINGER patch doesn't work so well after all. 
> The problem is that right after the TEARDOWN reply has been sent to the client,
> the connection is closed. Because SO_LINGER is now off, it discards any data
> that might still be in the send buffers and sends a RST to the client. This
> sometimes causes the client to fail to read the reply of the TEARDOWN.
> I also tried to set the linger parameter to something else than 0, which causes
> the TCP stack to wait for this amount of seconds before clearing and reseting
> the connection. With a 5 second linger, this made things work again.
> Also, SO_LINGER doesn't seem to be well supported/implemented on all platforms.
> I'm considering revering the patch...

I see your point and can confirm this...  The problem seems to occur only when the client is killed and effectively "orphans" the connection anyway causing the timeout to have to end the connection on the server end.  I ran into this debugging the client when I was abruptly killing it and restarting rapidly.  Sorry if I wasted your time.
Comment 13 Wim Taymans 2010-08-20 14:07:33 UTC
no problem. I disabled it for now but there is still a define in the code just so that we don't forget about it.

commit af732fa7492c592c6ce7fd8b6092354e64f4675b
Author: Wim Taymans <wim.taymans@collabora.co.uk>
Date:   Fri Aug 20 10:18:34 2010 +0200

    server: disable use of SO_LINGER
    
    SO_LINGER cause the client to fail to receive a TEARDOWN message because the
    server close()s the connection.
Comment 14 Wim Taymans 2010-08-20 14:18:13 UTC
(In reply to comment #10)
> (In reply to comment #9)
> > (In reply to comment #8)
> > > I agree that the multicast address should be done on the media-factory.  
> > 
> > I think it should even be done on the rtsp-media level, on second thoughts.
> I can work on this.  I will submit a patch when it is complete.  Would you like
> me to open a separate ticket for it?

yes, please.