From 41d25ebcc8bc8601bd66f5435c75fdff25cadc17 Mon Sep 17 00:00:00 2001 From: reimar Date: Sun, 27 Jun 2010 15:04:13 +0000 Subject: stream: 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. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31566 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/asf_streaming.c | 2 +- stream/librtsp/rtsp.c | 3 ++- stream/librtsp/rtsp_rtp.c | 2 +- stream/network.c | 2 +- stream/network.h | 6 ++++++ stream/stream_ftp.c | 6 +++--- stream/stream_netstream.h | 2 +- 7 files changed, 15 insertions(+), 8 deletions(-) (limited to 'stream') diff --git a/stream/asf_streaming.c b/stream/asf_streaming.c index baf42c748d..94563ef0f1 100644 --- a/stream/asf_streaming.c +++ b/stream/asf_streaming.c @@ -727,7 +727,7 @@ static int asf_http_streaming_start( stream_t *stream, int *demuxer_type ) { 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_tmsg(MSGT_NETWORK,MSGL_ERR,"socket write error: %s\n",strerror(errno)); goto err_out; diff --git a/stream/librtsp/rtsp.c b/stream/librtsp/rtsp.c index 53ed233c53..82669616ac 100644 --- a/stream/librtsp/rtsp.c +++ b/stream/librtsp/rtsp.c @@ -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 char *buf, int len) { 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; diff --git a/stream/librtsp/rtsp_rtp.c b/stream/librtsp/rtsp_rtp.c index 37400e62d1..0a8eed3392 100644 --- a/stream/librtsp/rtsp_rtp.c +++ b/stream/librtsp/rtsp_rtp.c @@ -93,7 +93,7 @@ rtcp_send_rr (rtsp_t *s, struct rtp_rtsp_session_t *st) { 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 */ diff --git a/stream/network.c b/stream/network.c index 11c8a2d460..cf01bf7144 100644 --- a/stream/network.c +++ b/stream/network.c @@ -274,7 +274,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_tmsg(MSGT_NETWORK,MSGL_ERR,"Error while sending HTTP request: Didn't send all the request.\n"); goto err_out; diff --git a/stream/network.h b/stream/network.h index b842b1ed24..897f697304 100644 --- a/stream/network.h +++ b/stream/network.h @@ -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 diff --git a/stream/stream_ftp.c b/stream/stream_ftp.c index 1df2f897c9..69dc326641 100644 --- a/stream/stream_ftp.c +++ b/stream/stream_ftp.c @@ -213,7 +213,7 @@ static int FtpSendCmd(const char *cmd, struct stream_priv_s *nControl,char* rsp) 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)); @@ -343,8 +343,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); diff --git a/stream/stream_netstream.h b/stream/stream_netstream.h index 4d3e30e849..3843ee938d 100644 --- a/stream/stream_netstream.h +++ b/stream/stream_netstream.h @@ -124,7 +124,7 @@ static mp_net_stream_packet_t* read_packet(int fd) { 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) -- cgit v1.2.3