diff options
author | sobomax <sobomax@FreeBSD.org> | 2005-03-08 16:11:41 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2005-03-08 16:11:41 +0000 |
commit | b795e2430a08adbe58c55709aea6123ff893cd2c (patch) | |
tree | 1842bc070cb153ce22a7b4ee51aa302dcc101ccc /sys/compat | |
parent | b5abf2d5ef025e11acb3131ee5eb160f78c3c95b (diff) | |
download | FreeBSD-src-b795e2430a08adbe58c55709aea6123ff893cd2c.zip FreeBSD-src-b795e2430a08adbe58c55709aea6123ff893cd2c.tar.gz |
Add kernel-only flag MSG_NOSIGNAL to be used in emulation layers to surpress
SIGPIPE signal for the duration of the sento-family syscalls. Use it to
replace previously added hack in Linux layer based on temporarily setting
SO_NOSIGPIPE flag.
Suggested by: alfred
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/linux/linux_socket.c | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 6f6f501..9ae7662 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -322,6 +322,8 @@ linux_to_bsd_msg_flags(int flags) ret_flags |= MSG_EOR; if (flags & LINUX_MSG_WAITALL) ret_flags |= MSG_WAITALL; + if (flags & LINUX_MSG_NOSIGNAL) + ret_flags |= MSG_NOSIGNAL; #if 0 /* not handled */ if (flags & LINUX_MSG_PROXY) ; @@ -335,8 +337,6 @@ linux_to_bsd_msg_flags(int flags) ; if (flags & LINUX_MSG_ERRQUEUE) ; - if (flags & LINUX_MSG_NOSIGNAL) - ; #endif return ret_flags; } @@ -816,41 +816,18 @@ linux_send(struct thread *td, struct linux_send_args *args) caddr_t to; int tolen; } */ bsd_args; - int error, nosigpipe, onosigpipe; - socklen_t valsize; + int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); - if (linux_args.flags & LINUX_MSG_NOSIGNAL) { - valsize = sizeof(onosigpipe); - error = kern_getsockopt(td, linux_args.s, SOL_SOCKET, - SO_NOSIGPIPE, &onosigpipe, UIO_SYSSPACE, - &valsize); - if (error != 0) - return error; - if (onosigpipe == 0) { - nosigpipe = 1; - error = kern_setsockopt(td, linux_args.s, SOL_SOCKET, - SO_NOSIGPIPE, &nosigpipe, UIO_SYSSPACE, - sizeof(nosigpipe)); - if (error != 0) - return error; - } - } bsd_args.s = linux_args.s; bsd_args.buf = (caddr_t)PTRIN(linux_args.msg); bsd_args.len = linux_args.len; bsd_args.flags = linux_args.flags; bsd_args.to = NULL; bsd_args.tolen = 0; - error = sendto(td, &bsd_args); - if ((linux_args.flags & LINUX_MSG_NOSIGNAL) && (onosigpipe == 0)) { - kern_setsockopt(td, linux_args.s, SOL_SOCKET, - SO_NOSIGPIPE, &onosigpipe, UIO_SYSSPACE, - sizeof(onosigpipe)); - } - return error; + return sendto(td, &bsd_args); } struct linux_recv_args { |