aboutsummaryrefslogtreecommitdiffstats
path: root/src/thread.h
diff options
context:
space:
mode:
authorEli Zaretskii2016-12-19 19:11:16 +0200
committerEli Zaretskii2016-12-19 19:11:16 +0200
commitfe3188b1cecc7ac5534616c8edf14a84b1b3bbb0 (patch)
tree39041b114c679f98255e9c95f2b4666d6f269ab2 /src/thread.h
parent657bcaf5ac30449915e070c3fa80a2eaaf1ee7e1 (diff)
downloademacs-fe3188b1cecc7ac5534616c8edf14a84b1b3bbb0.tar.gz
emacs-fe3188b1cecc7ac5534616c8edf14a84b1b3bbb0.zip
Fix crashes upon C-g on Posix TTY frames
* src/thread.h (struct thread_state): New member not_holding_lock. (maybe_reacquire_global_lock): Add prototype. * src/thread.c: Include syssignal.h. (maybe_reacquire_global_lock): New function. (really_call_select): Set the not_holding_lock member of the thread state before releasing the lock, and rest it after re-acquiring the lock when the select function returns. Block SIGINT while doing this to make sure we are not interrupted on TTY frames. * src/sysdep.c (block_interrupt_signal, restore_signal_mask): New functions. * src/syssignal.h (block_interrupt_signal, restore_signal_mask): Add prototypes. * src/keyboard.c (read_char) [THREADS_ENABLED]: Call maybe_reacquire_global_lock. (Bug#25178)
Diffstat (limited to 'src/thread.h')
-rw-r--r--src/thread.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/thread.h b/src/thread.h
index e6084b13c22..7dee67d6595 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -171,6 +171,13 @@ struct thread_state
171 interrupter should broadcast to this condition. */ 171 interrupter should broadcast to this condition. */
172 sys_cond_t *wait_condvar; 172 sys_cond_t *wait_condvar;
173 173
174 /* This thread might have released the global lock. If so, this is
175 non-zero. When a thread runs outside thread_select with this
176 flag non-zero, it means it has been interrupted by SIGINT while
177 in thread_select, and didn't have a chance of acquiring the lock.
178 It must do so ASAP. */
179 int not_holding_lock;
180
174 /* Threads are kept on a linked list. */ 181 /* Threads are kept on a linked list. */
175 struct thread_state *next_thread; 182 struct thread_state *next_thread;
176}; 183};
@@ -224,6 +231,7 @@ extern void unmark_threads (void);
224extern void finalize_one_thread (struct thread_state *state); 231extern void finalize_one_thread (struct thread_state *state);
225extern void finalize_one_mutex (struct Lisp_Mutex *); 232extern void finalize_one_mutex (struct Lisp_Mutex *);
226extern void finalize_one_condvar (struct Lisp_CondVar *); 233extern void finalize_one_condvar (struct Lisp_CondVar *);
234extern void maybe_reacquire_global_lock (void);
227 235
228extern void init_threads_once (void); 236extern void init_threads_once (void);
229extern void init_threads (void); 237extern void init_threads (void);