If the remote end of a connection oriented socket hangs up, generating an EPIPE error is preferable over an unhandled SIGPIPE signal.
Unified · Split
| @@ -98,6 +98,10 @@ struct sockaddr_storage { · 97 unmodified lines | ||
| 98 | 98 | }; |
| 99 | 99 | #endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */ |
| 100 | 100 | |
| 101 | +#ifndef MSG_NOSIGNAL | |
| 102 | +#define MSG_NOSIGNAL 0 | |
| 103 | +#endif | |
| 104 | + | |
| 101 | 105 | #if !HAVE_STRUCT_ADDRINFO |
| 102 | 106 | struct addrinfo { |
| 103 | 107 | int ai_flags; |
| @@ -143,7 +143,7 @@ static int ff_sctp_send(int s, const void *msg, size_t len, · 142 unmodified lines | ||
| 143 | 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 | |
| 149 | 149 | typedef struct SCTPContext { |
| @@ -300,7 +300,7 @@ static int sctp_write(URLContext *h, const uint8_t *buf, int size) · 150 unmodified lines | ||
| 300 | 300 | abort(); |
| 301 | 301 | ret = ff_sctp_send(s->fd, buf + 2, size - 2, &info, MSG_EOR); |
| 302 | 302 | } else |
| 303 | − ret = send(s->fd, buf, size, 0); | |
| 303 | + ret = send(s->fd, buf, size, MSG_NOSIGNAL); | |
| 304 | 304 | |
| 305 | 305 | return ret < 0 ? ff_neterrno() : ret; |
| 306 | 306 | } |
| @@ -154,7 +154,7 @@ static int tcp_write(URLContext *h, const uint8_t *buf, int size) · 153 unmodified lines | ||
| 154 | 154 | if (ret < 0) |
| 155 | 155 | return ret; |
| 156 | 156 | } |
| 157 | − ret = send(s->fd, buf, size, 0); | |
| 157 | + ret = send(s->fd, buf, size, MSG_NOSIGNAL); | |
| 158 | 158 | return ret < 0 ? ff_neterrno() : ret; |
| 159 | 159 | } |
| 160 | 160 | |
| @@ -124,7 +124,7 @@ static int unix_write(URLContext *h, const uint8_t *buf, int size) · 123 unmodified lines | ||
| 124 | 124 | if (ret < 0) |
| 125 | 125 | return ret; |
| 126 | 126 | } |
| 127 | − ret = send(s->fd, buf, size, 0); | |
| 127 | + ret = send(s->fd, buf, size, MSG_NOSIGNAL); | |
| 128 | 128 | return ret < 0 ? ff_neterrno() : ret; |
| 129 | 129 | } |
| 130 | 130 | |