- 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.
This commit is contained in:
parent
4146ac03bb
commit
966aaf884d
|
@ -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 @@ selrecord_knote(struct selinfo *sip, struct knote *kn)
|
|||
* 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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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 @@ filt_sordetach(struct knote *kn)
|
|||
|
||||
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 @@ filt_sowdetach(struct knote *kn)
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ filt_fifordetach(struct knote *kn)
|
|||
|
||||
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 @@ filt_fifowdetach(struct knote *kn)
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ int selcommon(register_t *, int, fd_set *, fd_set *, fd_set *,
|
|||
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 *);
|
||||
|
|
Loading…
Reference in New Issue