Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Sep 2005 10:35:36 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 83533 for review
Message-ID:  <200509131035.j8DAZaOV039404@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=83533

Change 83533 by rwatson@rwatson_zoo on 2005/09/13 10:35:22

	Kqueue and sockets guarantee that socket buffers will be locked
	when entering the filter for a socket buffer event.  Assert instead
	of conditionally acquiring.

Affected files ...

.. //depot/projects/netsmp/src/sys/fs/fifofs/fifo_vnops.c#11 edit

Differences ...

==== //depot/projects/netsmp/src/sys/fs/fifofs/fifo_vnops.c#11 (text+ko) ====

@@ -393,22 +393,16 @@
 filt_fiforead(struct knote *kn, long hint)
 {
 	struct socket *so = (struct socket *)kn->kn_hook;
-	int need_lock, result;
 
-	need_lock = !SOCKBUF_OWNED(&so->so_rcv);
-	if (need_lock)
-		SOCKBUF_LOCK(&so->so_rcv);
+	SOCKBUF_LOCK_ASSERT(&so->so_rcv);
 	kn->kn_data = so->so_rcv.sb_cc;
 	if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
 		kn->kn_flags |= EV_EOF;
-		result = 1;
+		return (1);
 	} else {
 		kn->kn_flags &= ~EV_EOF;
-		result = (kn->kn_data > 0);
+		return (kn->kn_data > 0);
 	}
-	if (need_lock)
-		SOCKBUF_UNLOCK(&so->so_rcv);
-	return (result);
 }
 
 static void
@@ -427,22 +421,16 @@
 filt_fifowrite(struct knote *kn, long hint)
 {
 	struct socket *so = (struct socket *)kn->kn_hook;
-	int need_lock, result;
 
-	need_lock = !SOCKBUF_OWNED(&so->so_snd);
-	if (need_lock)
-		SOCKBUF_LOCK(&so->so_snd);
+	SOCKBUF_LOCK_ASSERT(&so->so_snd);
 	kn->kn_data = sbspace(&so->so_snd);
 	if (so->so_snd.sb_state & SBS_CANTSENDMORE) {
 		kn->kn_flags |= EV_EOF;
-		result = 1;
+		return (1);
 	} else {
 		kn->kn_flags &= ~EV_EOF;
-	        result = (kn->kn_data >= so->so_snd.sb_lowat);
+	        return (kn->kn_data >= so->so_snd.sb_lowat);
 	}
-	if (need_lock)
-		SOCKBUF_UNLOCK(&so->so_snd);
-	return (result);
 }
 
 static void



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