summaryrefslogtreecommitdiff
path: root/lib/stream.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-06-22 10:38:53 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-06-27 20:01:22 -0400
commit03ed85a6c065896c9377db173745c511ea40bdcb (patch)
treed012b6a0947e947e943e05aee3c4851f6dc9d8d1 /lib/stream.c
parent34fa08703676b24b8d982b4717a769d68b2df2f4 (diff)
lib, zebra: Add a bit of code to look at fifo
When in a dev build add a bit of code to track max depth of a fifo and to allow zebra to report on it. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/stream.c')
-rw-r--r--lib/stream.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/stream.c b/lib/stream.c
index aba4c20166..a172eedc99 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -1109,6 +1109,10 @@ struct stream_fifo *stream_fifo_new(void)
/* Add new stream to fifo. */
void stream_fifo_push(struct stream_fifo *fifo, struct stream *s)
{
+#if defined DEV_BUILD
+ size_t max, curmax;
+#endif
+
if (fifo->tail)
fifo->tail->next = s;
else
@@ -1116,8 +1120,15 @@ void stream_fifo_push(struct stream_fifo *fifo, struct stream *s)
fifo->tail = s;
fifo->tail->next = NULL;
-
+#if !defined DEV_BUILD
atomic_fetch_add_explicit(&fifo->count, 1, memory_order_release);
+#else
+ max = atomic_fetch_add_explicit(&fifo->count, 1, memory_order_release);
+ curmax = atomic_load_explicit(&fifo->max_count, memory_order_relaxed);
+ if (max > curmax)
+ atomic_store_explicit(&fifo->max_count, max,
+ memory_order_relaxed);
+#endif
}
void stream_fifo_push_safe(struct stream_fifo *fifo, struct stream *s)