History

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.

Rémi Denis-Courmont committed 12 years ago

Commit 6ee1cb51 parent b263f8f4 files · +8 −4Browse files

Unified · Split

4 files
  1. libavformat/network.h +4 −0
  2. libavformat/sctp.c +2 −2
  3. libavformat/tcp.c +1 −1
  4. libavformat/unix.c +1 −1
libavformat/network.h+4−0
@@ -98,6 +98,10 @@ struct sockaddr_storage { · 97 unmodified lines
98};98};
99#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */99#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
100 100
101#ifndef MSG_NOSIGNAL
102#define MSG_NOSIGNAL 0
103#endif
104
101#if !HAVE_STRUCT_ADDRINFO105#if !HAVE_STRUCT_ADDRINFO
102struct addrinfo {106struct addrinfo {
103 int ai_flags;107 int ai_flags;
libavformat/sctp.c+2−2
@@ -143,7 +143,7 @@ static int ff_sctp_send(int s, const void *msg, size_t len, · 142 unmodified lines
143 memcpy(CMSG_DATA(cmsg), sinfo, sizeof(struct sctp_sndrcvinfo));143 memcpy(CMSG_DATA(cmsg), sinfo, sizeof(struct sctp_sndrcvinfo));
144 }144 }
145 145
146 return sendmsg(s, &outmsg, flags);146 return sendmsg(s, &outmsg, flags | MSG_NOSIGNAL);
147}147}
148 148
149typedef struct SCTPContext {149typedef struct SCTPContext {
@@ -300,7 +300,7 @@ static int sctp_write(URLContext *h, const uint8_t *buf, int size) · 150 unmodified lines
300 abort();300 abort();
301 ret = ff_sctp_send(s->fd, buf + 2, size - 2, &info, MSG_EOR);301 ret = ff_sctp_send(s->fd, buf + 2, size - 2, &info, MSG_EOR);
302 } else302 } else
303 ret = send(s->fd, buf, size, 0);303 ret = send(s->fd, buf, size, MSG_NOSIGNAL);
304 304
305 return ret < 0 ? ff_neterrno() : ret;305 return ret < 0 ? ff_neterrno() : ret;
306}306}
libavformat/tcp.c+1−1
@@ -154,7 +154,7 @@ static int tcp_write(URLContext *h, const uint8_t *buf, int size) · 153 unmodified lines
154 if (ret < 0)154 if (ret < 0)
155 return ret;155 return ret;
156 }156 }
157 ret = send(s->fd, buf, size, 0);157 ret = send(s->fd, buf, size, MSG_NOSIGNAL);
158 return ret < 0 ? ff_neterrno() : ret;158 return ret < 0 ? ff_neterrno() : ret;
159}159}
160 160
libavformat/unix.c+1−1
@@ -124,7 +124,7 @@ static int unix_write(URLContext *h, const uint8_t *buf, int size) · 123 unmodified lines
124 if (ret < 0)124 if (ret < 0)
125 return ret;125 return ret;
126 }126 }
127 ret = send(s->fd, buf, size, 0);127 ret = send(s->fd, buf, size, MSG_NOSIGNAL);
128 return ret < 0 ? ff_neterrno() : ret;128 return ret < 0 ? ff_neterrno() : ret;
129}129}
130 130

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t