Download raw body.
unlock socket close
On Mon, Jul 14, 2025 at 08:18:07PM +0200, Alexander Bluhm wrote:
> This diff is needed to run close(2) system call with shared netlock.
After parts have been commited, this is the remaining chunk that
actually swiches soclose() and sofree() to shared netlock.
bluhm
Index: kern/uipc_socket.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/kern/uipc_socket.c,v
diff -u -p -r1.380 uipc_socket.c
--- kern/uipc_socket.c 2 Jul 2025 16:44:40 -0000 1.380
+++ kern/uipc_socket.c 14 Jul 2025 22:29:29 -0000
@@ -213,10 +213,7 @@ socreate(int dom, struct socket **aso, i
if (error) {
so->so_state |= SS_NOFDREF;
/* sofree() calls sounlock(). */
- soref(so);
- sofree(so, 1);
- sounlock_shared(so);
- sorele(so);
+ sofree(so, 0);
return (error);
}
sounlock_shared(so);
@@ -304,7 +301,7 @@ sofree(struct socket *so, int keep_lock)
if (so->so_pcb || (so->so_state & SS_NOFDREF) == 0) {
if (!keep_lock)
- sounlock(so);
+ sounlock_shared(so);
return;
}
if (so->so_head) {
@@ -317,7 +314,7 @@ sofree(struct socket *so, int keep_lock)
*/
if (so->so_onq == &head->so_q) {
if (!keep_lock)
- sounlock(so);
+ sounlock_shared(so);
return;
}
@@ -344,7 +341,7 @@ sofree(struct socket *so, int keep_lock)
}
if (!keep_lock)
- sounlock(so);
+ sounlock_shared(so);
sorele(so);
}
@@ -368,7 +365,7 @@ soclose(struct socket *so, int flags)
struct socket *so2;
int error = 0;
- solock(so);
+ solock_shared(so);
/* Revoke async IO early. There is a final revocation in sofree(). */
sigio_free(&so->so_sigio);
if (so->so_state & SS_ISCONNECTED) {
@@ -430,7 +427,7 @@ discard:
if (so->so_sp) {
struct socket *soback;
- sounlock(so);
+ sounlock_shared(so);
/*
* Concurrent sounsplice() locks `sb_mtx' mutexes on
* both `so_snd' and `so_rcv' before unsplice sockets.
@@ -477,7 +474,7 @@ notsplicedback:
task_del(sosplice_taskq, &so->so_sp->ssp_task);
taskq_barrier(sosplice_taskq);
- solock(so);
+ solock_shared(so);
}
#endif /* SOCKET_SPLICE */
unlock socket close