diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2023-04-28 12:53:43 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2023-04-28 12:53:43 +0000 |
commit | f53f85fa202e8dba9c2ee5346e4081ec453ab5ee (patch) | |
tree | a3d420f2766bb7e3981a0558c8ea1bc09d0a181e /sys/kern | |
parent | 0e33fa30f0539596a72ba9ec503c8ca387a7698e (diff) |
Add a membar_consumer() for the taskq_create() in sosplice(). Membar
producer and consumer must come in pair and the latter was missing.
Also move the code a bit to make clear which check is needed for
what.
OK mvs@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_socket.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 3c8d08b774a..0c3b5bb52a5 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.302 2023/04/24 09:20:09 mvs Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.303 2023/04/28 12:53:42 bluhm Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -1258,14 +1258,19 @@ sosplice(struct socket *so, int fd, off_t max, struct timeval *tv) if (sosplice_taskq == NULL) { tq = taskq_create("sosplice", 1, IPL_SOFTNET, TASKQ_MPSAFE); + if (tq == NULL) { + rw_exit_write(&sosplice_lock); + return (ENOMEM); + } /* Ensure the taskq is fully visible to other CPUs. */ membar_producer(); sosplice_taskq = tq; } rw_exit_write(&sosplice_lock); + } else { + /* Ensure the taskq is fully visible on this CPU. */ + membar_consumer(); } - if (sosplice_taskq == NULL) - return (ENOMEM); if ((so->so_proto->pr_flags & PR_SPLICE) == 0) return (EPROTONOSUPPORT); |