Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Nov 2008 00:20:51 +0000 (UTC)
From:      Kip Macy <kmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r185193 - head/sys/sys
Message-ID:  <200811230020.mAN0KpYQ033357@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kmacy
Date: Sun Nov 23 00:20:51 2008
New Revision: 185193
URL: http://svn.freebsd.org/changeset/base/185193

Log:
  buf_ring_peek should return NULL if the ring is empty rather than
  whatever happened to be at cons_tail last time it was in use

Modified:
  head/sys/sys/buf_ring.h

Modified: head/sys/sys/buf_ring.h
==============================================================================
--- head/sys/sys/buf_ring.h	Sun Nov 23 00:16:10 2008	(r185192)
+++ head/sys/sys/buf_ring.h	Sun Nov 23 00:20:51 2008	(r185193)
@@ -216,7 +216,10 @@ buf_ring_peek(struct buf_ring *br)
 		panic("lock not held on single consumer dequeue");
 #endif	
 	mb();
-	return (br->br_ring[br->br_cons_tail]);
+	if (br->br_cons_head == br->br_prod_tail)
+		return (NULL);
+	
+	return (br->br_ring[br->br_cons_head]);
 }
 
 static __inline int



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