rtsp: avoid crashing on SIGPIPE

Use send() instead of write() so that we can pass the MSG_NOSIGNAL flags to
avoid crashing with SIGPIPE when the remote end is not listening to us anymore.

Fixes #601772
This commit is contained in:
Sreerenj B 2009-11-13 11:16:44 +01:00 committed by Wim Taymans
parent 18f5fad785
commit f3b3dd33f3

View file

@ -114,9 +114,15 @@ typedef struct
guint coutl; guint coutl;
} DecodeCtx; } DecodeCtx;
#ifdef MSG_NOSIGNAL
#define SEND_FLAGS MSG_NOSIGNAL
#else
#define SEND_FLAGS 0
#endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#define READ_SOCKET(fd, buf, len) recv (fd, (char *)buf, len, 0) #define READ_SOCKET(fd, buf, len) recv (fd, (char *)buf, len, 0)
#define WRITE_SOCKET(fd, buf, len) send (fd, (const char *)buf, len, 0) #define WRITE_SOCKET(fd, buf, len) send (fd, (const char *)buf, len, SEND_FLAGS)
#define SETSOCKOPT(sock, level, name, val, len) setsockopt (sock, level, name, (const char *)val, len) #define SETSOCKOPT(sock, level, name, val, len) setsockopt (sock, level, name, (const char *)val, len)
#define CLOSE_SOCKET(sock) closesocket (sock) #define CLOSE_SOCKET(sock) closesocket (sock)
#define ERRNO_IS_EAGAIN (WSAGetLastError () == WSAEWOULDBLOCK) #define ERRNO_IS_EAGAIN (WSAGetLastError () == WSAEWOULDBLOCK)
@ -126,7 +132,7 @@ typedef struct
#define ERRNO_IS_EINPROGRESS (WSAGetLastError () == WSAEWOULDBLOCK) #define ERRNO_IS_EINPROGRESS (WSAGetLastError () == WSAEWOULDBLOCK)
#else #else
#define READ_SOCKET(fd, buf, len) read (fd, buf, len) #define READ_SOCKET(fd, buf, len) read (fd, buf, len)
#define WRITE_SOCKET(fd, buf, len) write (fd, buf, len) #define WRITE_SOCKET(fd, buf, len) send (fd, buf, len, SEND_FLAGS)
#define SETSOCKOPT(sock, level, name, val, len) setsockopt (sock, level, name, val, len) #define SETSOCKOPT(sock, level, name, val, len) setsockopt (sock, level, name, val, len)
#define CLOSE_SOCKET(sock) close (sock) #define CLOSE_SOCKET(sock) close (sock)
#define ERRNO_IS_EAGAIN (errno == EAGAIN) #define ERRNO_IS_EAGAIN (errno == EAGAIN)