aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-05-21 21:33:48 +0200
committerHarald Welte <laforge@osmocom.org>2020-05-21 21:34:30 +0200
commit2e24003aba101eaf07c44f8efa08faa337d020c7 (patch)
treea45e94b826cd703e297f9369e9e4005d9242b096
parent6370f5dd6f05ce7bb95f2811a70b06462f321b72 (diff)
context: Ensure constructor runs after talloc constructorlaforge/talloc
-rw-r--r--src/context.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/context.c b/src/context.c
index bad012bd..9792b88f 100644
--- a/src/context.c
+++ b/src/context.c
@@ -43,8 +43,11 @@ int osmo_ctx_init(const char *id)
return 0;
}
-/* initialize osmo_ctx on main tread */
-static __attribute__((constructor)) void on_dso_load_ctx(void)
+/* initialize osmo_ctx on main thread. Use a very large priority value
+ * for the constructor attribute in order to ensure this is called after the
+ * talloc-internal constructor, which is setting up the randomized magic value
+ * in talloc_lib_init(). */
+static __attribute__((constructor(65535))) void on_dso_load_ctx(void)
{
OSMO_ASSERT(osmo_ctx_init("main") == 0);
}