diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-04-17 11:43:03 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-04-17 11:43:03 -0400 |
commit | feee98903cd8119d9a3db62589246a940f44a9f5 (patch) | |
tree | 37922ce54f00145d7fc0ac795216fce611e0806a /src/network | |
parent | 90f09a0dde3b37ebfabc4d3f6e2bb64086b7e804 (diff) | |
download | musl-feee98903cd8119d9a3db62589246a940f44a9f5.zip musl-feee98903cd8119d9a3db62589246a940f44a9f5.tar.gz musl-feee98903cd8119d9a3db62589246a940f44a9f5.tar.bz2 |
overhaul pthread cancellation
this patch improves the correctness, simplicity, and size of
cancellation-related code. modulo any small errors, it should now be
completely conformant, safe, and resource-leak free.
the notion of entering and exiting cancellation-point context has been
completely eliminated and replaced with alternative syscall assembly
code for cancellable syscalls. the assembly is responsible for setting
up execution context information (stack pointer and address of the
syscall instruction) which the cancellation signal handler can use to
determine whether the interrupted code was in a cancellable state.
these changes eliminate race conditions in the previous generation of
cancellation handling code (whereby a cancellation request received
just prior to the syscall would not be processed, leaving the syscall
to block, potentially indefinitely), and remedy an issue where
non-cancellable syscalls made from signal handlers became cancellable
if the signal handler interrupted a cancellation point.
x86_64 asm is untested and may need a second try to get it right.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/accept.c | 6 | ||||
-rw-r--r-- | src/network/connect.c | 6 | ||||
-rw-r--r-- | src/network/recvfrom.c | 6 | ||||
-rw-r--r-- | src/network/recvmsg.c | 4 | ||||
-rw-r--r-- | src/network/sendmsg.c | 6 | ||||
-rw-r--r-- | src/network/sendto.c | 6 |
6 files changed, 6 insertions, 28 deletions
diff --git a/src/network/accept.c b/src/network/accept.c index 46adff5..f6b75ba 100644 --- a/src/network/accept.c +++ b/src/network/accept.c @@ -4,9 +4,5 @@ int accept(int fd, struct sockaddr *addr, socklen_t *len) { - int ret; - CANCELPT_BEGIN; - ret = socketcall(accept, fd, addr, len, 0, 0, 0); - CANCELPT_END; - return ret; + return socketcall_cp(accept, fd, addr, len, 0, 0, 0); } diff --git a/src/network/connect.c b/src/network/connect.c index 29bffbc..57f01a1 100644 --- a/src/network/connect.c +++ b/src/network/connect.c @@ -4,9 +4,5 @@ int connect(int fd, const struct sockaddr *addr, socklen_t len) { - int ret; - CANCELPT_BEGIN; - ret = socketcall(connect, fd, addr, len, 0, 0, 0); - CANCELPT_END; - return ret; + return socketcall_cp(connect, fd, addr, len, 0, 0, 0); } diff --git a/src/network/recvfrom.c b/src/network/recvfrom.c index d522293..035a15f 100644 --- a/src/network/recvfrom.c +++ b/src/network/recvfrom.c @@ -4,9 +4,5 @@ ssize_t recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *alen) { - ssize_t r; - CANCELPT_BEGIN; - r = socketcall(recvfrom, fd, buf, len, flags, addr, alen); - CANCELPT_END; - return r; + return socketcall_cp(recvfrom, fd, buf, len, flags, addr, alen); } diff --git a/src/network/recvmsg.c b/src/network/recvmsg.c index 65094fc..4f52665 100644 --- a/src/network/recvmsg.c +++ b/src/network/recvmsg.c @@ -14,9 +14,7 @@ ssize_t recvmsg(int fd, struct msghdr *msg, int flags) msg = &h; } #endif - CANCELPT_BEGIN; - r = socketcall(recvmsg, fd, msg, flags, 0, 0, 0); - CANCELPT_END; + r = socketcall_cp(recvmsg, fd, msg, flags, 0, 0, 0); #if LONG_MAX > INT_MAX if (orig) *orig = h; #endif diff --git a/src/network/sendmsg.c b/src/network/sendmsg.c index 047c0ef..164c28d 100644 --- a/src/network/sendmsg.c +++ b/src/network/sendmsg.c @@ -5,7 +5,6 @@ ssize_t sendmsg(int fd, const struct msghdr *msg, int flags) { - ssize_t r; #if LONG_MAX > INT_MAX struct msghdr h; if (msg) { @@ -14,8 +13,5 @@ ssize_t sendmsg(int fd, const struct msghdr *msg, int flags) msg = &h; } #endif - CANCELPT_BEGIN; - r = socketcall(sendmsg, fd, msg, flags, 0, 0, 0); - CANCELPT_END; - return r; + return socketcall_cp(sendmsg, fd, msg, flags, 0, 0, 0); } diff --git a/src/network/sendto.c b/src/network/sendto.c index 1cfc621..899eecf 100644 --- a/src/network/sendto.c +++ b/src/network/sendto.c @@ -4,9 +4,5 @@ ssize_t sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen) { - ssize_t r; - CANCELPT_BEGIN; - r = socketcall(sendto, fd, buf, len, flags, addr, alen); - CANCELPT_END; - return r; + return socketcall_cp(sendto, fd, buf, len, flags, addr, alen); } |