fix crash on invalid configurations by setting thread pointer and log buffer to a statically allocated descriptor until the threading structures have been initialized properly
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
33c89f0d47
commit
12cc159949
4 changed files with 11 additions and 2 deletions
|
@ -110,6 +110,7 @@ dds_init(void)
|
|||
os_mutexInit (&gv.static_logbuf_lock);
|
||||
gv.static_logbuf_lock_inited = 1;
|
||||
os_mutexInit (&dds_global.m_mutex);
|
||||
thread_states_init_static();
|
||||
|
||||
uri = os_getenv (DDSC_PROJECT_NAME_NOSPACE_CAPS"_URI");
|
||||
dds_cfgst = config_init (uri);
|
||||
|
|
|
@ -86,6 +86,7 @@ struct thread_states {
|
|||
extern struct thread_states thread_states;
|
||||
extern os_threadLocal struct thread_state1 *tsd_thread_state;
|
||||
|
||||
void thread_states_init_static (void);
|
||||
void thread_states_init (_In_ unsigned maxthreads);
|
||||
void thread_states_fini (void);
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ static void nn_vlogb (struct thread_state1 *self, const char *fmt, va_list ap)
|
|||
logbuf_t lb;
|
||||
if (*fmt == 0)
|
||||
return;
|
||||
if (self && self->lb)
|
||||
if (self->lb)
|
||||
lb = self->lb;
|
||||
else
|
||||
{
|
||||
|
|
|
@ -56,6 +56,13 @@ static void os_free_aligned ( _Pre_maybenull_ _Post_invalid_ void *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
void thread_states_init_static (void)
|
||||
{
|
||||
static struct thread_state1 ts =
|
||||
{ .state = THREAD_STATE_ALIVE, .vtime = 1, .watchdog = 1, .lb = NULL, .name = "(anon)" };
|
||||
tsd_thread_state = &ts;
|
||||
}
|
||||
|
||||
void thread_states_init (_In_ unsigned maxthreads)
|
||||
{
|
||||
unsigned i;
|
||||
|
@ -324,7 +331,7 @@ void downgrade_main_thread (void)
|
|||
logbuf_free (ts1->lb);
|
||||
/* no need to sync with service lease: already stopped */
|
||||
reap_thread_state (ts1, 0);
|
||||
tsd_thread_state = NULL;
|
||||
thread_states_init_static ();
|
||||
}
|
||||
|
||||
struct thread_state1 *get_thread_state (_In_ os_threadId id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue