From: Wim Taymans Date: Fri, 20 Aug 2010 08:18:34 +0000 (+0200) Subject: server: disable use of SO_LINGER X-Git-Tag: 1.19.3~495^2~1459 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af732fa7492c592c6ce7fd8b6092354e64f4675b;p=platform%2Fupstream%2Fgstreamer.git 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. --- diff --git a/gst/rtsp-server/rtsp-server.c b/gst/rtsp-server/rtsp-server.c index cc03456..3399a66 100644 --- a/gst/rtsp-server/rtsp-server.c +++ b/gst/rtsp-server/rtsp-server.c @@ -27,6 +27,11 @@ #define DEFAULT_SERVICE "8554" #define DEFAULT_BACKLOG 5 +/* Define to use the SO_LINGER option so that the server sockets can be resused + * sooner. Disabled for now because it is not very well implemented by various + * OSes and it causes clients to fail to read the TEARDOWN response. */ +#undef USE_SOLINGER + enum { PROP_0, @@ -421,7 +426,9 @@ gst_rtsp_server_sink_init_send (GstRTSPServer * server) int ret, sockfd; struct addrinfo hints; struct addrinfo *result, *rp; +#ifdef USE_SOLINGER struct linger linger; +#endif memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */ @@ -477,13 +484,16 @@ gst_rtsp_server_sink_init_send (GstRTSPServer * server) (void *) &ret, sizeof (ret)) < 0) goto keepalive_failed; - /* make sure socket is reset immediately after close. This ensure that we can - * reuse the socket quickly. */ +#ifdef USE_SOLINGER + /* make sure socket is reset 5 seconds after close. This ensure that we can + * reuse the socket quickly while still having a chance to send data to the + * client. */ linger.l_onoff = 1; linger.l_linger = 5; if (setsockopt (server->server_sock.fd, SOL_SOCKET, SO_LINGER, (void *) &linger, sizeof (linger)) < 0) goto linger_failed; +#endif /* set the server socket to nonblocking */ fcntl (server->server_sock.fd, F_SETFL, O_NONBLOCK); @@ -522,11 +532,13 @@ keepalive_failed: GST_ERROR_OBJECT (server, "failed to configure keepalive socket: %s", g_strerror (errno)); goto close_error; } +#ifdef USE_SOLINGER linger_failed: { GST_ERROR_OBJECT (server, "failed to no linger socket: %s", g_strerror (errno)); goto close_error; } +#endif listen_failed: { GST_ERROR_OBJECT (server, "failed to listen on socket: %s", g_strerror (errno));