Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use MSG_NOSIGNAL if SOCK_NOSIGPIPE not available #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/libknc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2250,6 +2250,18 @@ fdwritev(void *cookie, const struct iovec *iov, int iovcnt)

#ifdef O_NOSIGPIPE
return writev(fd, iov, iovcnt);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just always use sendmsg(2) and reduce the amount of #ifdef mess by a teeny bit.

#else
#ifdef MSG_NOSIGNAL
struct msghdr msg = { 0 };

msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = (void *)(uintptr_t)iov;
msg.msg_iovlen = iovcnt;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = 0;
return sendmsg(fd, &msg, MSG_NOSIGNAL);
#else
struct timespec ts_zero = {0, 0};
sigset_t blocked;
Expand Down Expand Up @@ -2293,6 +2305,7 @@ fdwritev(void *cookie, const struct iovec *iov, int iovcnt)
errno = my_errno;
return ret;
#endif
#endif
}

static int
Expand Down