summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2018-11-19 13:15:38 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2018-11-19 13:15:38 +0000
commit0b9426ab228141fe19c2c87efedb86a47cfcb2bc (patch)
tree2186f351a6438d2e87bc8f8e0a2d5c07de521629 /sys/kern
parent0be3d260a91999ad8021a08efa6a4f0db72a86b9 (diff)
Utilize sigio with sockets.
OK mpi@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/sys_socket.c10
-rw-r--r--sys/kern/uipc_socket.c12
-rw-r--r--sys/kern/uipc_socket2.c11
3 files changed, 17 insertions, 16 deletions
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c
index 22b3e266654..0676d907f32 100644
--- a/sys/kern/sys_socket.c
+++ b/sys/kern/sys_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_socket.c,v 1.41 2018/08/20 16:00:22 mpi Exp $ */
+/* $OpenBSD: sys_socket.c,v 1.42 2018/11/19 13:15:37 visa Exp $ */
/* $NetBSD: sys_socket.c,v 1.13 1995/08/12 23:59:09 mycroft Exp $ */
/*
@@ -114,17 +114,15 @@ soo_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p)
case TIOCSPGRP:
/* FALLTHROUGH */
case SIOCSPGRP:
- so->so_pgid = *(int *)data;
- so->so_siguid = p->p_ucred->cr_ruid;
- so->so_sigeuid = p->p_ucred->cr_uid;
+ error = sigio_setown(&so->so_sigio, *(int *)data);
break;
case TIOCGPGRP:
- *(int *)data = -so->so_pgid;
+ *(int *)data = -sigio_getown(&so->so_sigio);
break;
case SIOCGPGRP:
- *(int *)data = so->so_pgid;
+ *(int *)data = sigio_getown(&so->so_sigio);
break;
case SIOCATMARK:
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index d50b6dd1914..94d5afafe73 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.227 2018/08/21 12:34:11 bluhm Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.228 2018/11/19 13:15:37 visa Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -129,6 +129,7 @@ socreate(int dom, struct socket **aso, int type, int proto)
if (prp->pr_type != type)
return (EPROTOTYPE);
so = pool_get(&socket_pool, PR_WAITOK | PR_ZERO);
+ sigio_init(&so->so_sigio);
TAILQ_INIT(&so->so_q0);
TAILQ_INIT(&so->so_q);
so->so_type = type;
@@ -214,6 +215,7 @@ sofree(struct socket *so, int s)
return;
}
}
+ sigio_free(&so->so_sigio);
#ifdef SOCKET_SPLICE
if (so->so_sp) {
if (issplicedback(so))
@@ -250,6 +252,8 @@ soclose(struct socket *so, int flags)
int s, error = 0;
s = solock(so);
+ /* Revoke async IO early. There is a final revocation in sofree(). */
+ sigio_free(&so->so_sigio);
if (so->so_options & SO_ACCEPTCONN) {
while ((so2 = TAILQ_FIRST(&so->so_q0)) != NULL) {
(void) soqremque(so2, 0);
@@ -1921,7 +1925,7 @@ void
sohasoutofband(struct socket *so)
{
KERNEL_LOCK();
- csignal(so->so_pgid, SIGURG, so->so_siguid, so->so_sigeuid);
+ pgsigio(&so->so_sigio, SIGURG, 0);
selwakeup(&so->so_rcv.sb_sel);
KERNEL_UNLOCK();
}
@@ -2080,6 +2084,7 @@ so_print(void *v,
(*pr)("so_state: 0x%04x\n", so->so_state);
(*pr)("so_pcb: %p\n", so->so_pcb);
(*pr)("so_proto: %p\n", so->so_proto);
+ (*pr)("so_sigio: %p\n", so->so_sigio.sir_sigio);
(*pr)("so_head: %p\n", so->so_head);
(*pr)("so_onq: %p\n", so->so_onq);
@@ -2090,9 +2095,6 @@ so_print(void *v,
(*pr)("so_qlen: %i\n", so->so_qlen);
(*pr)("so_qlimit: %i\n", so->so_qlimit);
(*pr)("so_timeo: %i\n", so->so_timeo);
- (*pr)("so_pgid: %i\n", so->so_pgid);
- (*pr)("so_siguid: %i\n", so->so_siguid);
- (*pr)("so_sigeuid: %i\n", so->so_sigeuid);
(*pr)("so_obmark: %lu\n", so->so_oobmark);
(*pr)("so_sp: %p\n", so->so_sp);
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c
index fcd93f8f26c..cb6dedcb1a8 100644
--- a/sys/kern/uipc_socket2.c
+++ b/sys/kern/uipc_socket2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket2.c,v 1.98 2018/11/09 14:14:31 claudio Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.99 2018/11/19 13:15:37 visa Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
@@ -166,14 +166,11 @@ sonewconn(struct socket *head, int connstatus)
so->so_state = head->so_state | SS_NOFDREF;
so->so_proto = head->so_proto;
so->so_timeo = head->so_timeo;
- so->so_pgid = head->so_pgid;
so->so_euid = head->so_euid;
so->so_ruid = head->so_ruid;
so->so_egid = head->so_egid;
so->so_rgid = head->so_rgid;
so->so_cpid = head->so_cpid;
- so->so_siguid = head->so_siguid;
- so->so_sigeuid = head->so_sigeuid;
/*
* Inherit watermarks but those may get clamped in low mem situations.
@@ -189,9 +186,13 @@ sonewconn(struct socket *head, int connstatus)
so->so_rcv.sb_lowat = head->so_rcv.sb_lowat;
so->so_rcv.sb_timeo = head->so_rcv.sb_timeo;
+ sigio_init(&so->so_sigio);
+ sigio_copy(&so->so_sigio, &head->so_sigio);
+
soqinsque(head, so, soqueue);
if ((*so->so_proto->pr_attach)(so, 0)) {
(void) soqremque(so, soqueue);
+ sigio_free(&so->so_sigio);
pool_put(&socket_pool, so);
return (NULL);
}
@@ -408,7 +409,7 @@ sowakeup(struct socket *so, struct sockbuf *sb)
}
KERNEL_LOCK();
if (so->so_state & SS_ASYNC)
- csignal(so->so_pgid, SIGIO, so->so_siguid, so->so_sigeuid);
+ pgsigio(&so->so_sigio, SIGIO, 0);
selwakeup(&sb->sb_sel);
KERNEL_UNLOCK();
}