Change in libosmocore[master]: rate_ctr: Make it safe to call rate_ctr_init() several times

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sun Nov 14 19:46:18 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/26235 )


Change subject: rate_ctr: Make it safe to call rate_ctr_init() several times
......................................................................

rate_ctr: Make it safe to call rate_ctr_init() several times

There might be library code that has rate counters, and if the main
program calls rate_ctr_init() a second time, we can skip the second
initialization.

Change-Id: I6f5342a77518599eb5ac9a0f0605917a78fcc387
---
M src/rate_ctr.c
1 file changed, 4 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/35/26235/1

diff --git a/src/rate_ctr.c b/src/rate_ctr.c
index 4d99699..283858d 100644
--- a/src/rate_ctr.c
+++ b/src/rate_ctr.c
@@ -354,6 +354,10 @@
  *  \returns 0 on success; negative on error */
 int rate_ctr_init(void *tall_ctx)
 {
+	/* ignore repeated initialization */
+	if (osmo_timer_pending(&rate_ctr_timer))
+		return 0;
+
 	tall_rate_ctr_ctx = tall_ctx;
 	osmo_timer_setup(&rate_ctr_timer, rate_ctr_timer_cb, NULL);
 	osmo_timer_schedule(&rate_ctr_timer, 1, 0);

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/26235
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6f5342a77518599eb5ac9a0f0605917a78fcc387
Gerrit-Change-Number: 26235
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211114/21e67971/attachment.htm>


More information about the gerrit-log mailing list