Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys - Change selremove_knote() from returning void to bool, ...
details: https://anonhg.NetBSD.org/src/rev/8dbe486154fc
branches: trunk
changeset: 1023858:8dbe486154fc
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Sep 29 02:47:22 2021 +0000
description:
- Change selremove_knote() from returning void to bool, and return
true if the last knote was removed and there are no more knotes
on the selinfo.
- Use this new return value in filt_sordetach(), filt_sowdetach(),
filt_fifordetach(), and filt_fifowdetach() to know when to clear
SB_KOTE without having to know select/kqueue implementation details.
diffstat:
sys/kern/sys_select.c | 10 +++++++---
sys/kern/uipc_socket.c | 14 ++++++--------
sys/miscfs/fifofs/fifo_vnops.c | 14 ++++++--------
sys/sys/select.h | 4 ++--
4 files changed, 21 insertions(+), 21 deletions(-)
diffs (137 lines):
diff -r b256384c5c34 -r 8dbe486154fc sys/kern/sys_select.c
--- a/sys/kern/sys_select.c Tue Sep 28 15:35:44 2021 +0000
+++ b/sys/kern/sys_select.c Wed Sep 29 02:47:22 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_select.c,v 1.55 2020/12/11 01:25:29 thorpej Exp $ */
+/* $NetBSD: sys_select.c,v 1.56 2021/09/29 02:47:22 thorpej Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009, 2010, 2019, 2020 The NetBSD Foundation, Inc.
@@ -84,7 +84,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.55 2020/12/11 01:25:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.56 2021/09/29 02:47:22 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -682,11 +682,15 @@
* Remove a knote.
*
* The caller holds the same lock as for selrecord().
+ *
+ * Returns true if the last knote was removed and the list
+ * is now empty.
*/
-void
+bool
selremove_knote(struct selinfo *sip, struct knote *kn)
{
SLIST_REMOVE(&sip->sel_klist, kn, knote, kn_selnext);
+ return SLIST_EMPTY(&sip->sel_klist);
}
/*
diff -r b256384c5c34 -r 8dbe486154fc sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c Tue Sep 28 15:35:44 2021 +0000
+++ b/sys/kern/uipc_socket.c Wed Sep 29 02:47:22 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_socket.c,v 1.296 2021/09/26 01:16:10 thorpej Exp $ */
+/* $NetBSD: uipc_socket.c,v 1.297 2021/09/29 02:47:22 thorpej Exp $ */
/*
* Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.296 2021/09/26 01:16:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.297 2021/09/29 02:47:22 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -2225,9 +2225,8 @@
so = ((file_t *)kn->kn_obj)->f_socket;
solock(so);
- selremove_knote(&so->so_rcv.sb_sel, kn);
- if (SLIST_EMPTY(&so->so_rcv.sb_sel.sel_klist)) /* XXX select/kqueue */
- so->so_rcv.sb_flags &= ~SB_KNOTE; /* XXX internals */
+ if (selremove_knote(&so->so_rcv.sb_sel, kn))
+ so->so_rcv.sb_flags &= ~SB_KNOTE;
sounlock(so);
}
@@ -2264,9 +2263,8 @@
so = ((file_t *)kn->kn_obj)->f_socket;
solock(so);
- selremove_knote(&so->so_snd.sb_sel, kn);
- if (SLIST_EMPTY(&so->so_snd.sb_sel.sel_klist)) /* XXX select/kqueue */
- so->so_snd.sb_flags &= ~SB_KNOTE; /* XXX internals */
+ if (selremove_knote(&so->so_snd.sb_sel, kn))
+ so->so_snd.sb_flags &= ~SB_KNOTE;
sounlock(so);
}
diff -r b256384c5c34 -r 8dbe486154fc sys/miscfs/fifofs/fifo_vnops.c
--- a/sys/miscfs/fifofs/fifo_vnops.c Tue Sep 28 15:35:44 2021 +0000
+++ b/sys/miscfs/fifofs/fifo_vnops.c Wed Sep 29 02:47:22 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fifo_vnops.c,v 1.84 2021/09/26 01:16:10 thorpej Exp $ */
+/* $NetBSD: fifo_vnops.c,v 1.85 2021/09/29 02:47:22 thorpej Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fifo_vnops.c,v 1.84 2021/09/26 01:16:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fifo_vnops.c,v 1.85 2021/09/29 02:47:22 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -516,9 +516,8 @@
so = (struct socket *)kn->kn_hook;
solock(so);
- selremove_knote(&so->so_rcv.sb_sel, kn);
- if (SLIST_EMPTY(&so->so_rcv.sb_sel.sel_klist)) /* XXX select/kqueue */
- so->so_rcv.sb_flags &= ~SB_KNOTE; /* XXX internals */
+ if (selremove_knote(&so->so_rcv.sb_sel, kn))
+ so->so_rcv.sb_flags &= ~SB_KNOTE;
sounlock(so);
}
@@ -551,9 +550,8 @@
so = (struct socket *)kn->kn_hook;
solock(so);
- selremove_knote(&so->so_snd.sb_sel, kn);
- if (SLIST_EMPTY(&so->so_snd.sb_sel.sel_klist)) /* XXX select/kqueue */
- so->so_snd.sb_flags &= ~SB_KNOTE; /* XXX internals */
+ if (selremove_knote(&so->so_snd.sb_sel, kn))
+ so->so_snd.sb_flags &= ~SB_KNOTE;
sounlock(so);
}
diff -r b256384c5c34 -r 8dbe486154fc sys/sys/select.h
--- a/sys/sys/select.h Tue Sep 28 15:35:44 2021 +0000
+++ b/sys/sys/select.h Wed Sep 29 02:47:22 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: select.h,v 1.38 2020/12/11 01:25:29 thorpej Exp $ */
+/* $NetBSD: select.h,v 1.39 2021/09/29 02:47:22 thorpej Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -53,7 +53,7 @@
struct timespec *, sigset_t *);
void selrecord(struct lwp *selector, struct selinfo *);
void selrecord_knote(struct selinfo *, struct knote *);
-void selremove_knote(struct selinfo *, struct knote *);
+bool selremove_knote(struct selinfo *, struct knote *);
void selnotify(struct selinfo *, int, long);
void selsysinit(struct cpu_info *);
void selinit(struct selinfo *);
Home |
Main Index |
Thread Index |
Old Index