Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Mar 2010 19:59:00 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r205463 - stable/8/sys/net
Message-ID:  <201003221959.o2MJx0SX024571@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Mon Mar 22 19:59:00 2010
New Revision: 205463
URL: http://svn.freebsd.org/changeset/base/205463

Log:
  MFC:	r205092
  
  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]

Modified:
  stable/8/sys/net/bpf.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/net/bpf.c
==============================================================================
--- stable/8/sys/net/bpf.c	Mon Mar 22 19:52:06 2010	(r205462)
+++ stable/8/sys/net/bpf.c	Mon Mar 22 19:59:00 2010	(r205463)
@@ -611,6 +611,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);
 }
@@ -648,7 +649,7 @@ bpfopen(struct cdev *dev, int flags, int
 	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);
@@ -804,13 +805,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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003221959.o2MJx0SX024571>