summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmacy <kmacy@FreeBSD.org>2008-11-23 00:20:51 +0000
committerkmacy <kmacy@FreeBSD.org>2008-11-23 00:20:51 +0000
commitdbca5c7f4665de31b65585b87aa802ef84a65917 (patch)
treeb04c546c45c8bfe51bec42f428afaea7a116726e
parent3bf236fa908dc58e40fadd54c9f1389536e866be (diff)
downloadFreeBSD-src-dbca5c7f4665de31b65585b87aa802ef84a65917.zip
FreeBSD-src-dbca5c7f4665de31b65585b87aa802ef84a65917.tar.gz
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
-rw-r--r--sys/sys/buf_ring.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/sys/buf_ring.h b/sys/sys/buf_ring.h
index d77814a..8563f29 100644
--- a/sys/sys/buf_ring.h
+++ b/sys/sys/buf_ring.h
@@ -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
OpenPOWER on IntegriCloud