From 9c1f56ec71a68e945ff7315ae710f6f9f03e8cc8 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 7 Mar 2004 14:41:45 +0100 Subject: Avoiding too many consecutive "ring buffer overflow" messages --- ringbuffer.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'ringbuffer.c') diff --git a/ringbuffer.c b/ringbuffer.c index 5eee41ec..6f26748a 100644 --- a/ringbuffer.c +++ b/ringbuffer.c @@ -7,7 +7,7 @@ * Parts of this file were inspired by the 'ringbuffy.c' from the * LinuxDVB driver (see linuxtv.org). * - * $Id: ringbuffer.c 1.18 2003/10/18 10:29:25 kls Exp $ + * $Id: ringbuffer.c 1.19 2004/03/07 13:46:51 kls Exp $ */ #include "ringbuffer.h" @@ -17,6 +17,8 @@ // --- cRingBuffer ----------------------------------------------------------- +#define OVERFLOWREPORTDELTA 5 // seconds between reports + cRingBuffer::cRingBuffer(int Size, bool Statistics) { size = Size; @@ -24,6 +26,8 @@ cRingBuffer::cRingBuffer(int Size, bool Statistics) maxFill = 0; lastPercent = 0; putTimeout = getTimeout = 0; + lastOverflowReport = 0; + overflowCount = overflowBytes = 0; } cRingBuffer::~cRingBuffer() @@ -68,6 +72,17 @@ void cRingBuffer::SetTimeouts(int PutTimeout, int GetTimeout) getTimeout = GetTimeout; } +void cRingBuffer::ReportOverflow(int Bytes) +{ + overflowCount++; + overflowBytes += Bytes; + if (time(NULL) - lastOverflowReport > OVERFLOWREPORTDELTA) { + esyslog("ERROR: %d ring buffer overflow%s (%d bytes dropped)", overflowCount, overflowCount > 1 ? "s" : "", overflowBytes); + overflowCount = overflowBytes = 0; + lastOverflowReport = time(NULL); + } +} + // --- cRingBufferLinear ----------------------------------------------------- cRingBufferLinear::cRingBufferLinear(int Size, int Margin, bool Statistics) -- cgit v1.2.3