changeset 31500:b01f807eb183

Use MSG_NOSIGNAL flag if available for send(). This avoids MPlayer quitting due to SIGPIPE at least for these cases. Ignoring SIGPIPE in general would break window-closing with some window-managers.
author reimar
date Sun, 27 Jun 2010 15:04:13 +0000
parents c0fdef79a5d5
children 71917902699c
files stream/asf_streaming.c stream/librtsp/rtsp.c stream/librtsp/rtsp_rtp.c stream/network.c stream/network.h stream/stream_ftp.c stream/stream_netstream.h
diffstat 7 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/stream/asf_streaming.c	Sun Jun 27 15:01:24 2010 +0000
+++ b/stream/asf_streaming.c	Sun Jun 27 15:04:13 2010 +0000
@@ -728,7 +728,7 @@
 		http_hdr = asf_http_request( stream->streaming_ctrl );
 		mp_msg(MSGT_NETWORK,MSGL_DBG2,"Request [%s]\n", http_hdr->buffer );
 		for(i=0; i < (int)http_hdr->buffer_size ; ) {
-			int r = send( fd, http_hdr->buffer+i, http_hdr->buffer_size-i, 0 );
+			int r = send( fd, http_hdr->buffer+i, http_hdr->buffer_size-i, DEFAULT_SEND_FLAGS );
 			if(r <0) {
 				mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_SocketWriteError,strerror(errno));
 				goto err_out;
--- a/stream/librtsp/rtsp.c	Sun Jun 27 15:01:24 2010 +0000
+++ b/stream/librtsp/rtsp.c	Sun Jun 27 15:04:13 2010 +0000
@@ -51,6 +51,7 @@
 #include "rtsp.h"
 #include "rtsp_session.h"
 #include "osdep/timer.h"
+#include "stream/network.h"
 
 /*
 #define LOG
@@ -67,7 +68,7 @@
   while (total < len){
     int n;
 
-    n = send (s, &buf[total], len - total, 0);
+    n = send (s, &buf[total], len - total, DEFAULT_SEND_FLAGS);
 
     if (n > 0)
       total += n;
--- a/stream/librtsp/rtsp_rtp.c	Sun Jun 27 15:01:24 2010 +0000
+++ b/stream/librtsp/rtsp_rtp.c	Sun Jun 27 15:04:13 2010 +0000
@@ -93,7 +93,7 @@
   {
     char rtcp_content[RTCP_RR_SIZE];
     strcpy (rtcp_content, RTCP_RR);
-    send (st->rtcp_socket, rtcp_content, RTCP_RR_SIZE, 0);
+    send (st->rtcp_socket, rtcp_content, RTCP_RR_SIZE, DEFAULT_SEND_FLAGS);
 
     /* ping RTSP server to keep connection alive.
        we use OPTIONS instead of PING as not all servers support it */
--- a/stream/network.c	Sun Jun 27 15:01:24 2010 +0000
+++ b/stream/network.c	Sun Jun 27 15:04:13 2010 +0000
@@ -275,7 +275,7 @@
 	}
 	mp_msg(MSGT_NETWORK,MSGL_DBG2,"Request: [%s]\n", http_hdr->buffer );
 
-	ret = send( fd, http_hdr->buffer, http_hdr->buffer_size, 0 );
+	ret = send( fd, http_hdr->buffer, http_hdr->buffer_size, DEFAULT_SEND_FLAGS );
 	if( ret!=(int)http_hdr->buffer_size ) {
 		mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_ErrSendingHTTPRequest);
 		goto err_out;
--- a/stream/network.h	Sun Jun 27 15:01:24 2010 +0000
+++ b/stream/network.h	Sun Jun 27 15:04:13 2010 +0000
@@ -39,6 +39,12 @@
 #include "url.h"
 #include "http.h"
 
+#ifdef MSG_NOSIGNAL
+#define DEFAULT_SEND_FLAGS MSG_NOSIGNAL
+#else
+#define DEFAULT_SEND_FLAGS 0
+#endif
+
 #if !HAVE_CLOSESOCKET
 #define closesocket close
 #endif
--- a/stream/stream_ftp.c	Sun Jun 27 15:01:24 2010 +0000
+++ b/stream/stream_ftp.c	Sun Jun 27 15:04:13 2010 +0000
@@ -214,7 +214,7 @@
   if(hascrlf && l == 2) mp_msg(MSGT_STREAM,MSGL_V, "\n");
   else mp_msg(MSGT_STREAM,MSGL_V, "[ftp] > %s",cmd);
   while(l > 0) {
-    int s = send(nControl->handle,cmd,l,0);
+    int s = send(nControl->handle,cmd,l,DEFAULT_SEND_FLAGS);
 
     if(s <= 0) {
       mp_msg(MSGT_OPEN,MSGL_ERR, "[ftp] write error: %s\n",strerror(errno));
@@ -344,8 +344,8 @@
     //fcntl(p->handle,F_SETFL,fl&~O_NONBLOCK);
 
     // send only first byte as OOB due to OOB braindamage in many unices
-    send(p->handle,pre_cmd,1,MSG_OOB);
-    send(p->handle,pre_cmd+1,sizeof(pre_cmd)-1,0);
+    send(p->handle,pre_cmd,1,MSG_OOB|DEFAULT_SEND_FLAGS);
+    send(p->handle,pre_cmd+1,sizeof(pre_cmd)-1,DEFAULT_SEND_FLAGS);
 
     //fcntl(p->handle,F_SETFL,fl);
 
--- a/stream/stream_netstream.h	Sun Jun 27 15:01:24 2010 +0000
+++ b/stream/stream_netstream.h	Sun Jun 27 15:04:13 2010 +0000
@@ -124,7 +124,7 @@
 static int net_write(int fd, char* buf, int len) {
   int w;
   while(len) {
-    w = send(fd,buf,len,0);
+    w = send(fd,buf,len,DEFAULT_SEND_FLAGS);
     if(w <= 0) {
       if(errno == EINTR) continue;
       if(w < 0)