summaryrefslogtreecommitdiff
path: root/src/thread.h
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2016-12-19 19:11:16 +0200
committerEli Zaretskii <eliz@gnu.org>2016-12-19 19:11:16 +0200
commitfe3188b1cecc7ac5534616c8edf14a84b1b3bbb0 (patch)
tree39041b114c679f98255e9c95f2b4666d6f269ab2 /src/thread.h
parent657bcaf5ac30449915e070c3fa80a2eaaf1ee7e1 (diff)
downloademacs-fe3188b1cecc7ac5534616c8edf14a84b1b3bbb0.tar.gz
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
interrupter should broadcast to this condition. */
sys_cond_t *wait_condvar;
+ /* This thread might have released the global lock. If so, this is
+ non-zero. When a thread runs outside thread_select with this
+ flag non-zero, it means it has been interrupted by SIGINT while
+ in thread_select, and didn't have a chance of acquiring the lock.
+ It must do so ASAP. */
+ int not_holding_lock;
+
/* Threads are kept on a linked list. */
struct thread_state *next_thread;
};
@@ -224,6 +231,7 @@ extern void unmark_threads (void);
extern void finalize_one_thread (struct thread_state *state);
extern void finalize_one_mutex (struct Lisp_Mutex *);
extern void finalize_one_condvar (struct Lisp_CondVar *);
+extern void maybe_reacquire_global_lock (void);
extern void init_threads_once (void);
extern void init_threads (void);