stream: Use MSG_NOSIGNAL
Without MSG_NOSIGNAL, sending to closed sockets will generate SIGPIPE.pull/80/head
parent
95742676c9
commit
b3c1d5d1dc
|
@ -25,6 +25,7 @@
|
||||||
#include <aml.h>
|
#include <aml.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#ifdef ENABLE_TLS
|
#ifdef ENABLE_TLS
|
||||||
#include <gnutls/gnutls.h>
|
#include <gnutls/gnutls.h>
|
||||||
|
@ -123,7 +124,11 @@ static int stream__flush_plain(struct stream* self)
|
||||||
if (n_msgs == 0)
|
if (n_msgs == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bytes_sent = writev(self->fd, iov, n_msgs);
|
struct msghdr msghdr = {
|
||||||
|
.msg_iov = iov,
|
||||||
|
.msg_iovlen = n_msgs,
|
||||||
|
};
|
||||||
|
bytes_sent = sendmsg(self->fd, &msghdr, MSG_NOSIGNAL);
|
||||||
if (bytes_sent < 0) {
|
if (bytes_sent < 0) {
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
stream__poll_rw(self);
|
stream__poll_rw(self);
|
||||||
|
|
Loading…
Reference in New Issue