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
This commit is contained in:
reimar 2010-06-27 15:04:13 +00:00 committed by Uoti Urpala
parent e551352121
commit 41d25ebcc8
7 changed files with 15 additions and 8 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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)