summaryrefslogtreecommitdiffstats
path: root/sys/net/bpf.c
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2010-03-12 19:14:58 +0000
committerjkim <jkim@FreeBSD.org>2010-03-12 19:14:58 +0000
commitdf5e72589a498fae2b2d828d50b33878daae3d6f (patch)
treed94a5659ccd0569be846118016503c2660f4ac96 /sys/net/bpf.c
parentf74c6cc1b5f458a81b5afdd890deb29263d2a02a (diff)
downloadFreeBSD-src-df5e72589a498fae2b2d828d50b33878daae3d6f.zip
FreeBSD-src-df5e72589a498fae2b2d828d50b33878daae3d6f.tar.gz
Tidy up callout for select(2) and read timeout.
- Add a missing callout_drain(9) before the descriptor deallocation.[1] - Prefer callout_init_mtx(9) over callout_init(9) and let the callout subsystem handle the mutex for callout function. PR: kern/144453 Submitted by: Alexander Sack (asack at niksun dot com)[1] MFC after: 1 week
Diffstat (limited to 'sys/net/bpf.c')
-rw-r--r--sys/net/bpf.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 65e3f2b..3c50a49 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -614,6 +614,7 @@ bpf_dtor(void *data)
mac_bpfdesc_destroy(d);
#endif /* MAC */
knlist_destroy(&d->bd_sel.si_note);
+ callout_drain(&d->bd_callout);
bpf_freed(d);
free(d, M_BPF);
}
@@ -651,7 +652,7 @@ bpfopen(struct cdev *dev, int flags, int fmt, struct thread *td)
mac_bpfdesc_create(td->td_ucred, d);
#endif
mtx_init(&d->bd_mtx, devtoname(dev), "bpf cdev lock", MTX_DEF);
- callout_init(&d->bd_callout, CALLOUT_MPSAFE);
+ callout_init_mtx(&d->bd_callout, &d->bd_mtx, 0);
knlist_init_mtx(&d->bd_sel.si_note, &d->bd_mtx);
return (0);
@@ -807,13 +808,15 @@ bpf_timed_out(void *arg)
{
struct bpf_d *d = (struct bpf_d *)arg;
- BPFD_LOCK(d);
+ BPFD_LOCK_ASSERT(d);
+
+ if (callout_pending(&d->bd_callout) || !callout_active(&d->bd_callout))
+ return;
if (d->bd_state == BPF_WAITING) {
d->bd_state = BPF_TIMED_OUT;
if (d->bd_slen != 0)
bpf_wakeup(d);
}
- BPFD_UNLOCK(d);
}
static int
OpenPOWER on IntegriCloud