[MPlayer-cvslog] r31566 - in trunk/stream: asf_streaming.c librtsp/rtsp.c librtsp/rtsp_rtp.c network.c network.h stream_ftp.c stream_netstream.h

reimar subversion at mplayerhq.hu
Sun Jun 27 17:04:14 CEST 2010


Author: reimar
Date: Sun Jun 27 17:04:13 2010
New Revision: 31566

Log:
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.

Modified:
   trunk/stream/asf_streaming.c
   trunk/stream/librtsp/rtsp.c
   trunk/stream/librtsp/rtsp_rtp.c
   trunk/stream/network.c
   trunk/stream/network.h
   trunk/stream/stream_ftp.c
   trunk/stream/stream_netstream.h

Modified: trunk/stream/asf_streaming.c
==============================================================================
--- trunk/stream/asf_streaming.c	Sun Jun 27 17:01:24 2010	(r31565)
+++ trunk/stream/asf_streaming.c	Sun Jun 27 17:04:13 2010	(r31566)
@@ -728,7 +728,7 @@ static int asf_http_streaming_start( str
 		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;

Modified: trunk/stream/librtsp/rtsp.c
==============================================================================
--- trunk/stream/librtsp/rtsp.c	Sun Jun 27 17:01:24 2010	(r31565)
+++ trunk/stream/librtsp/rtsp.c	Sun Jun 27 17:04:13 2010	(r31566)
@@ -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 @@ static int write_stream(int s, const cha
   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;

Modified: trunk/stream/librtsp/rtsp_rtp.c
==============================================================================
--- trunk/stream/librtsp/rtsp_rtp.c	Sun Jun 27 17:01:24 2010	(r31565)
+++ trunk/stream/librtsp/rtsp_rtp.c	Sun Jun 27 17:04:13 2010	(r31566)
@@ -93,7 +93,7 @@ rtcp_send_rr (rtsp_t *s, struct rtp_rtsp
   {
     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 */

Modified: trunk/stream/network.c
==============================================================================
--- trunk/stream/network.c	Sun Jun 27 17:01:24 2010	(r31565)
+++ trunk/stream/network.c	Sun Jun 27 17:04:13 2010	(r31566)
@@ -275,7 +275,7 @@ http_send_request( URL_t *url, off_t pos
 	}
 	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;

Modified: trunk/stream/network.h
==============================================================================
--- trunk/stream/network.h	Sun Jun 27 17:01:24 2010	(r31565)
+++ trunk/stream/network.h	Sun Jun 27 17:04:13 2010	(r31566)
@@ -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

Modified: trunk/stream/stream_ftp.c
==============================================================================
--- trunk/stream/stream_ftp.c	Sun Jun 27 17:01:24 2010	(r31565)
+++ trunk/stream/stream_ftp.c	Sun Jun 27 17:04:13 2010	(r31566)
@@ -214,7 +214,7 @@ static int FtpSendCmd(const char *cmd, s
   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 @@ static int seek(stream_t *s,off_t newpos
     //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);
 

Modified: trunk/stream/stream_netstream.h
==============================================================================
--- trunk/stream/stream_netstream.h	Sun Jun 27 17:01:24 2010	(r31565)
+++ trunk/stream/stream_netstream.h	Sun Jun 27 17:04:13 2010	(r31566)
@@ -124,7 +124,7 @@ static mp_net_stream_packet_t* read_pack
 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)


More information about the MPlayer-cvslog mailing list