summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJafar Al-Gharaibeh <Jafaral@users.noreply.github.com>2018-06-29 19:41:02 +0200
committerGitHub <noreply@github.com>2018-06-29 19:41:02 +0200
commit20e5fd7ab52d37a0fade8dc6cd5b6070779a484d (patch)
tree4f2d03607e80e303892ec6757b19679a43045dda /lib
parentMerge pull request #2583 from donaldsharp/more_warnings (diff)
parentpimd: Remove redistribution request (diff)
downloadfrr-20e5fd7ab52d37a0fade8dc6cd5b6070779a484d.tar.xz
frr-20e5fd7ab52d37a0fade8dc6cd5b6070779a484d.zip
Merge pull request #2532 from donaldsharp/various_stuff
Redistribution and some extra developer debug code
Diffstat (limited to 'lib')
-rw-r--r--lib/stream.c13
-rw-r--r--lib/stream.h3
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/stream.c b/lib/stream.c
index aba4c2016..a172eedc9 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)
diff --git a/lib/stream.h b/lib/stream.h
index e5d325e43..11af85c66 100644
--- a/lib/stream.h
+++ b/lib/stream.h
@@ -115,6 +115,9 @@ struct stream_fifo {
/* number of streams in this fifo */
_Atomic size_t count;
+#if defined DEV_BUILD
+ _Atomic size_t max_count;
+#endif
struct stream *head;
struct stream *tail;