From 58c436e5a71f583694dd84ff241e23bedf6f71dd Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 30 Oct 2020 09:05:43 -0400 Subject: [PATCH] TT#98901 add ssrc_hash_foreach() Change-Id: Ia90fc84ee82afc78b8fa5b6f8fed160959636d28 --- daemon/ssrc.c | 10 ++++++++++ include/ssrc.h | 1 + 2 files changed, 11 insertions(+) diff --git a/daemon/ssrc.c b/daemon/ssrc.c index 2c3874dca..535e8c957 100644 --- a/daemon/ssrc.c +++ b/daemon/ssrc.c @@ -178,6 +178,16 @@ void free_ssrc_hash(struct ssrc_hash **ht) { g_slice_free1(sizeof(**ht), *ht); *ht = NULL; } +void ssrc_hash_foreach(struct ssrc_hash *sh, void (*f)(void *)) { + rwlock_lock_w(&sh->lock); + + for (GList *k = sh->q.head; k; k = k->next) + f(k->data); + if (sh->precreat) + f(sh->precreat); + + rwlock_unlock_w(&sh->lock); +} struct ssrc_hash *create_ssrc_hash_full(ssrc_create_func_t cfunc, void *uptr) { diff --git a/include/ssrc.h b/include/ssrc.h index 29c2b6fe4..e3d34e1b9 100644 --- a/include/ssrc.h +++ b/include/ssrc.h @@ -183,6 +183,7 @@ struct ssrc_xr_voip_metrics { void free_ssrc_hash(struct ssrc_hash **); +void ssrc_hash_foreach(struct ssrc_hash *, void (*)(void *)); struct ssrc_hash *create_ssrc_hash_full(ssrc_create_func_t, void *uptr); struct ssrc_hash *create_ssrc_hash_call(void);