diff options
author | kmacy <kmacy@FreeBSD.org> | 2008-11-23 00:20:51 +0000 |
---|---|---|
committer | kmacy <kmacy@FreeBSD.org> | 2008-11-23 00:20:51 +0000 |
commit | dbca5c7f4665de31b65585b87aa802ef84a65917 (patch) | |
tree | b04c546c45c8bfe51bec42f428afaea7a116726e /sys/sys/buf_ring.h | |
parent | 3bf236fa908dc58e40fadd54c9f1389536e866be (diff) | |
download | FreeBSD-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
Diffstat (limited to 'sys/sys/buf_ring.h')
-rw-r--r-- | sys/sys/buf_ring.h | 5 |
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 |