Review at  https://gerrit.osmocom.org/4562

Catch repeated calls to osmo_init_logging()

If an application calls osmo_init_logging() multiple times, let's
bail out in a safe way without corrupting the state + returning an
error.

Change-Id: Icf337a430fb367bbca48a1b02822a2cb3b644e5f
---
M src/application.c
1 file changed, 6 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/62/4562/1

diff --git a/src/application.c b/src/application.c
index ee22639..538ac45 100644
--- a/src/application.c
+++ b/src/application.c
@@ -112,6 +112,12 @@
  */
 int osmo_init_logging(const struct log_info *log_info)
 {
+       static int logging_initialized = 0;
+
+       if (logging_initialized)
+               return -EEXIST;
+
+       logging_initialized = 1;
        log_init(log_info, NULL);
        osmo_stderr_target = log_target_create_stderr();
        if (!osmo_stderr_target)

-- 
To view, visit https://gerrit.osmocom.org/4562
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icf337a430fb367bbca48a1b02822a2cb3b644e5f
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <[email protected]>

Reply via email to