[FFmpeg-cvslog] libavformat: use MSG_NOSIGNAL when applicable
Rémi Denis-Courmont
git at videolan.org
Mon Aug 25 13:33:18 CEST 2014
ffmpeg | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Aug 20 23:06:07 2014 +0300| [6ee1cb5740e7490151db7dcec7e20ceaf8a2fe1f] | committer: Martin Storsjö
libavformat: use MSG_NOSIGNAL when applicable
If the remote end of a connection oriented socket hangs up, generating
an EPIPE error is preferable over an unhandled SIGPIPE signal.
Signed-off-by: Martin Storsjö <martin at martin.st>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6ee1cb5740e7490151db7dcec7e20ceaf8a2fe1f
---
libavformat/network.h | 4 ++++
libavformat/sctp.c | 4 ++--
libavformat/tcp.c | 2 +-
libavformat/unix.c | 2 +-
4 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/libavformat/network.h b/libavformat/network.h
index 9d8c92f..09cee58 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -98,6 +98,10 @@ struct sockaddr_storage {
};
#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
+#ifndef MSG_NOSIGNAL
+#define MSG_NOSIGNAL 0
+#endif
+
#if !HAVE_STRUCT_ADDRINFO
struct addrinfo {
int ai_flags;
diff --git a/libavformat/sctp.c b/libavformat/sctp.c
index 66b31cc..84a4ac1 100644
--- a/libavformat/sctp.c
+++ b/libavformat/sctp.c
@@ -143,7 +143,7 @@ static int ff_sctp_send(int s, const void *msg, size_t len,
memcpy(CMSG_DATA(cmsg), sinfo, sizeof(struct sctp_sndrcvinfo));
}
- return sendmsg(s, &outmsg, flags);
+ return sendmsg(s, &outmsg, flags | MSG_NOSIGNAL);
}
typedef struct SCTPContext {
@@ -300,7 +300,7 @@ static int sctp_write(URLContext *h, const uint8_t *buf, int size)
abort();
ret = ff_sctp_send(s->fd, buf + 2, size - 2, &info, MSG_EOR);
} else
- ret = send(s->fd, buf, size, 0);
+ ret = send(s->fd, buf, size, MSG_NOSIGNAL);
return ret < 0 ? ff_neterrno() : ret;
}
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index cbd5142..27a0184 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -154,7 +154,7 @@ static int tcp_write(URLContext *h, const uint8_t *buf, int size)
if (ret < 0)
return ret;
}
- ret = send(s->fd, buf, size, 0);
+ ret = send(s->fd, buf, size, MSG_NOSIGNAL);
return ret < 0 ? ff_neterrno() : ret;
}
diff --git a/libavformat/unix.c b/libavformat/unix.c
index ab57c68..5c6f576 100644
--- a/libavformat/unix.c
+++ b/libavformat/unix.c
@@ -124,7 +124,7 @@ static int unix_write(URLContext *h, const uint8_t *buf, int size)
if (ret < 0)
return ret;
}
- ret = send(s->fd, buf, size, 0);
+ ret = send(s->fd, buf, size, MSG_NOSIGNAL);
return ret < 0 ? ff_neterrno() : ret;
}
More information about the ffmpeg-cvslog
mailing list