fix a few latent issues in the thread patch
* we called unbind_for_thread_switch unconditionally, but this is wrong if the previous thread exited * likewise, exiting a thread should clear current_thread * redundant assignment in run_thread * clean up init_threads - no need to re-init the primary thread This patch still sometimes causes weird hangs in "make check". However, I think that is a kernel bug, since Emacs enters the zombie state but its parent process hangs in wait. This shouldn't happen.
This commit is contained in:
parent
ac70709c2a
commit
313dfb6277
1 changed files with 10 additions and 6 deletions
16
src/thread.c
16
src/thread.c
|
@ -52,7 +52,11 @@ post_acquire_global_lock (struct thread_state *self)
|
|||
|
||||
if (self != current_thread)
|
||||
{
|
||||
unbind_for_thread_switch ();
|
||||
/* CURRENT_THREAD is NULL if the previously current thread
|
||||
exited. In this case, there is no reason to unbind, and
|
||||
trying will crash. */
|
||||
if (current_thread != NULL)
|
||||
unbind_for_thread_switch ();
|
||||
current_thread = self;
|
||||
rebind_for_thread_switch ();
|
||||
}
|
||||
|
@ -625,7 +629,7 @@ run_thread (void *state)
|
|||
struct thread_state **iter;
|
||||
|
||||
self->m_stack_bottom = &stack_pos;
|
||||
self->stack_top = self->m_stack_bottom = &stack_pos;
|
||||
self->stack_top = &stack_pos;
|
||||
self->thread_id = sys_thread_self ();
|
||||
|
||||
acquire_global_lock (self);
|
||||
|
@ -653,6 +657,7 @@ run_thread (void *state)
|
|||
self->m_specpdl_ptr = NULL;
|
||||
self->m_specpdl_size = 0;
|
||||
|
||||
current_thread = NULL;
|
||||
sys_cond_broadcast (&self->thread_condvar);
|
||||
|
||||
release_global_lock ();
|
||||
|
@ -905,8 +910,6 @@ init_primary_thread (void)
|
|||
primary_thread.error_symbol = Qnil;
|
||||
primary_thread.error_data = Qnil;
|
||||
primary_thread.event_object = Qnil;
|
||||
|
||||
sys_cond_init (&primary_thread.thread_condvar);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -918,10 +921,11 @@ init_threads_once (void)
|
|||
void
|
||||
init_threads (void)
|
||||
{
|
||||
init_primary_thread ();
|
||||
|
||||
sys_cond_init (&primary_thread.thread_condvar);
|
||||
sys_mutex_init (&global_lock);
|
||||
sys_mutex_lock (&global_lock);
|
||||
current_thread = &primary_thread;
|
||||
primary_thread.thread_id = sys_thread_self ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Reference in a new issue