mirror of https://gerrit.osmocom.org/libosmocore
on_dso_load_select: run after on_dso_load_ctx
Add priorities to ensure on_dso_load_select runs after on_dso_load_ctx.
Otherwise osmo_ctx->global (used via define OTC_GLOBAL) points to NULL
and causes a segfault in osmo_fd_lookup_table_extend.
Use numbers 101 and 102, as "0 to 100 are reserved for the
implementation" and cause an error from GCC.
Fixes: OS#5946
Fixes: c46a15d8
("select: Optimize osmo_fd_get_by_fd")
Change-Id: Ia2518e82530b93c535f8f5105513e21559b895ba
This commit is contained in:
parent
fc37650381
commit
b46cfba995
|
@ -39,7 +39,7 @@ int osmo_ctx_init(const char *id)
|
|||
}
|
||||
|
||||
/* initialize osmo_ctx on main tread */
|
||||
static __attribute__((constructor)) void on_dso_load_ctx(void)
|
||||
static __attribute__((constructor(101))) void on_dso_load_ctx(void)
|
||||
{
|
||||
OSMO_ASSERT(osmo_ctx_init("main") == 0);
|
||||
}
|
||||
|
|
|
@ -534,8 +534,9 @@ void osmo_select_init(void)
|
|||
osmo_fd_lookup_table_extend(0);
|
||||
}
|
||||
|
||||
/* ensure main thread always has pre-initialized osmo_fds */
|
||||
static __attribute__((constructor)) void on_dso_load_select(void)
|
||||
/* ensure main thread always has pre-initialized osmo_fds
|
||||
* priority 102: must run after on_dso_load_ctx */
|
||||
static __attribute__((constructor(102))) void on_dso_load_select(void)
|
||||
{
|
||||
osmo_select_init();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue