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
9898 };
9999 #endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
100100
101+#ifndef MSG_NOSIGNAL
102+#define MSG_NOSIGNAL 0
103+#endif
104+
101105 #if !HAVE_STRUCT_ADDRINFO
102106 struct addrinfo {
103107 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
143143 memcpy(CMSG_DATA(cmsg), sinfo, sizeof(struct sctp_sndrcvinfo));
144144 }
145145
146− return sendmsg(s, &outmsg, flags);
146+ return sendmsg(s, &outmsg, flags | MSG_NOSIGNAL);
147147 }
148148
149149 typedef struct SCTPContext {
@@ -300,7 +300,7 @@ static int sctp_write(URLContext *h, const uint8_t *buf, int size) · 150 unmodified lines
300300 abort();
301301 ret = ff_sctp_send(s->fd, buf + 2, size - 2, &info, MSG_EOR);
302302 } else
303− ret = send(s->fd, buf, size, 0);
303+ ret = send(s->fd, buf, size, MSG_NOSIGNAL);
304304
305305 return ret < 0 ? ff_neterrno() : ret;
306306 }
libavformat/tcp.c+1−1
@@ -154,7 +154,7 @@ static int tcp_write(URLContext *h, const uint8_t *buf, int size) · 153 unmodified lines
154154 if (ret < 0)
155155 return ret;
156156 }
157− ret = send(s->fd, buf, size, 0);
157+ ret = send(s->fd, buf, size, MSG_NOSIGNAL);
158158 return ret < 0 ? ff_neterrno() : ret;
159159 }
160160
libavformat/unix.c+1−1
@@ -124,7 +124,7 @@ static int unix_write(URLContext *h, const uint8_t *buf, int size) · 123 unmodified lines
124124 if (ret < 0)
125125 return ret;
126126 }
127− ret = send(s->fd, buf, size, 0);
127+ ret = send(s->fd, buf, size, MSG_NOSIGNAL);
128128 return ret < 0 ? ff_neterrno() : ret;
129129 }
130130

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