mirror of
https://github.com/openbsd/src.git
synced 2026-04-29 08:36:22 +00:00
Simplify filterops routines where klist_invalidate() is used.
klist_invalidate() detaches knotes from the list and rewires them synchronously so that the original filterops routines do not get called after the invalidation. OK anton@, mpi@
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: if_pppx.c,v 1.73 2020/01/24 06:42:13 jsg Exp $ */
|
||||
/* $OpenBSD: if_pppx.c,v 1.74 2020/01/28 16:26:09 visa Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org>
|
||||
@@ -541,9 +541,6 @@ filt_pppx_rdetach(struct knote *kn)
|
||||
struct pppx_dev *pxd = (struct pppx_dev *)kn->kn_hook;
|
||||
struct klist *klist = &pxd->pxd_rsel.si_note;
|
||||
|
||||
if (ISSET(kn->kn_status, KN_DETACHED))
|
||||
return;
|
||||
|
||||
mtx_enter(&pxd->pxd_rsel_mtx);
|
||||
SLIST_REMOVE(klist, kn, knote, kn_selnext);
|
||||
mtx_leave(&pxd->pxd_rsel_mtx);
|
||||
@@ -554,11 +551,6 @@ filt_pppx_read(struct knote *kn, long hint)
|
||||
{
|
||||
struct pppx_dev *pxd = (struct pppx_dev *)kn->kn_hook;
|
||||
|
||||
if (ISSET(kn->kn_status, KN_DETACHED)) {
|
||||
kn->kn_data = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
kn->kn_data = mq_hdatalen(&pxd->pxd_svcq);
|
||||
|
||||
return (kn->kn_data > 0);
|
||||
@@ -570,9 +562,6 @@ filt_pppx_wdetach(struct knote *kn)
|
||||
struct pppx_dev *pxd = (struct pppx_dev *)kn->kn_hook;
|
||||
struct klist *klist = &pxd->pxd_wsel.si_note;
|
||||
|
||||
if (ISSET(kn->kn_status, KN_DETACHED))
|
||||
return;
|
||||
|
||||
mtx_enter(&pxd->pxd_wsel_mtx);
|
||||
SLIST_REMOVE(klist, kn, knote, kn_selnext);
|
||||
mtx_leave(&pxd->pxd_wsel_mtx);
|
||||
@@ -1462,14 +1451,8 @@ pppackqfilter(dev_t dev, struct knote *kn)
|
||||
static void
|
||||
filt_pppac_rdetach(struct knote *kn)
|
||||
{
|
||||
struct pppac_softc *sc;
|
||||
struct klist *klist;
|
||||
|
||||
if (ISSET(kn->kn_status, KN_DETACHED))
|
||||
return;
|
||||
|
||||
sc = kn->kn_hook;
|
||||
klist = &sc->sc_rsel.si_note;
|
||||
struct pppac_softc *sc = kn->kn_hook;
|
||||
struct klist *klist = &sc->sc_rsel.si_note;
|
||||
|
||||
mtx_enter(&sc->sc_rsel_mtx);
|
||||
SLIST_REMOVE(klist, kn, knote, kn_selnext);
|
||||
@@ -1479,14 +1462,7 @@ filt_pppac_rdetach(struct knote *kn)
|
||||
static int
|
||||
filt_pppac_read(struct knote *kn, long hint)
|
||||
{
|
||||
struct pppac_softc *sc;
|
||||
|
||||
if (ISSET(kn->kn_status, KN_DETACHED)) {
|
||||
kn->kn_data = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
sc = kn->kn_hook;
|
||||
struct pppac_softc *sc = kn->kn_hook;
|
||||
|
||||
kn->kn_data = mq_hdatalen(&sc->sc_mq);
|
||||
|
||||
@@ -1496,14 +1472,8 @@ filt_pppac_read(struct knote *kn, long hint)
|
||||
static void
|
||||
filt_pppac_wdetach(struct knote *kn)
|
||||
{
|
||||
struct pppac_softc *sc;
|
||||
struct klist *klist;
|
||||
|
||||
if (ISSET(kn->kn_status, KN_DETACHED))
|
||||
return;
|
||||
|
||||
sc = kn->kn_hook;
|
||||
klist = &sc->sc_wsel.si_note;
|
||||
struct pppac_softc *sc = kn->kn_hook;
|
||||
struct klist *klist = &sc->sc_wsel.si_note;
|
||||
|
||||
mtx_enter(&sc->sc_wsel_mtx);
|
||||
SLIST_REMOVE(klist, kn, knote, kn_selnext);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: if_tun.c,v 1.214 2020/01/27 11:00:44 dlg Exp $ */
|
||||
/* $OpenBSD: if_tun.c,v 1.215 2020/01/28 16:26:09 visa Exp $ */
|
||||
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
@@ -1015,28 +1015,18 @@ void
|
||||
filt_tunrdetach(struct knote *kn)
|
||||
{
|
||||
int s;
|
||||
struct tun_softc *sc;
|
||||
struct tun_softc *sc = kn->kn_hook;
|
||||
|
||||
sc = (struct tun_softc *)kn->kn_hook;
|
||||
s = splhigh();
|
||||
if (!(kn->kn_status & KN_DETACHED))
|
||||
SLIST_REMOVE(&sc->sc_rsel.si_note, kn, knote, kn_selnext);
|
||||
SLIST_REMOVE(&sc->sc_rsel.si_note, kn, knote, kn_selnext);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
int
|
||||
filt_tunread(struct knote *kn, long hint)
|
||||
{
|
||||
struct tun_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
|
||||
if (kn->kn_status & KN_DETACHED) {
|
||||
kn->kn_data = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
sc = (struct tun_softc *)kn->kn_hook;
|
||||
ifp = &sc->sc_if;
|
||||
struct tun_softc *sc = kn->kn_hook;
|
||||
struct ifnet *ifp = &sc->sc_if;
|
||||
|
||||
kn->kn_data = ifq_hdatalen(&ifp->if_snd);
|
||||
|
||||
@@ -1047,28 +1037,18 @@ void
|
||||
filt_tunwdetach(struct knote *kn)
|
||||
{
|
||||
int s;
|
||||
struct tun_softc *sc;
|
||||
struct tun_softc *sc = kn->kn_hook;
|
||||
|
||||
sc = (struct tun_softc *)kn->kn_hook;
|
||||
s = splhigh();
|
||||
if (!(kn->kn_status & KN_DETACHED))
|
||||
SLIST_REMOVE(&sc->sc_wsel.si_note, kn, knote, kn_selnext);
|
||||
SLIST_REMOVE(&sc->sc_wsel.si_note, kn, knote, kn_selnext);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
int
|
||||
filt_tunwrite(struct knote *kn, long hint)
|
||||
{
|
||||
struct tun_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
|
||||
if (kn->kn_status & KN_DETACHED) {
|
||||
kn->kn_data = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
sc = (struct tun_softc *)kn->kn_hook;
|
||||
ifp = &sc->sc_if;
|
||||
struct tun_softc *sc = kn->kn_hook;
|
||||
struct ifnet *ifp = &sc->sc_if;
|
||||
|
||||
kn->kn_data = ifp->if_hdrlen + ifp->if_hardmtu;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: switchctl.c,v 1.18 2019/12/31 13:48:32 visa Exp $ */
|
||||
/* $OpenBSD: switchctl.c,v 1.19 2020/01/28 16:26:09 visa Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Kazuya GODA <goda@openbsd.org>
|
||||
@@ -420,9 +420,6 @@ filt_switch_rdetach(struct knote *kn)
|
||||
struct switch_softc *sc = (struct switch_softc *)kn->kn_hook;
|
||||
struct klist *klist = &sc->sc_swdev->swdev_rsel.si_note;
|
||||
|
||||
if (ISSET(kn->kn_status, KN_DETACHED))
|
||||
return;
|
||||
|
||||
SLIST_REMOVE(klist, kn, knote, kn_selnext);
|
||||
}
|
||||
|
||||
@@ -431,11 +428,6 @@ filt_switch_read(struct knote *kn, long hint)
|
||||
{
|
||||
struct switch_softc *sc = (struct switch_softc *)kn->kn_hook;
|
||||
|
||||
if (ISSET(kn->kn_status, KN_DETACHED)) {
|
||||
kn->kn_data = 0;
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (!mq_empty(&sc->sc_swdev->swdev_outq) ||
|
||||
sc->sc_swdev->swdev_lastm != NULL) {
|
||||
kn->kn_data = mq_len(&sc->sc_swdev->swdev_outq) +
|
||||
@@ -452,9 +444,6 @@ filt_switch_wdetach(struct knote *kn)
|
||||
struct switch_softc *sc = (struct switch_softc *)kn->kn_hook;
|
||||
struct klist *klist = &sc->sc_swdev->swdev_wsel.si_note;
|
||||
|
||||
if (ISSET(kn->kn_status, KN_DETACHED))
|
||||
return;
|
||||
|
||||
SLIST_REMOVE(klist, kn, knote, kn_selnext);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user