summaryrefslogtreecommitdiff
path: root/src/thread.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2017-11-24 23:37:42 +0200
committerEli Zaretskii <eliz@gnu.org>2017-11-24 23:37:42 +0200
commitf7fdaea4c0a2f4285d974a2870c4f6b465b40500 (patch)
tree014c77cb84fc9d338159d0f2a3f2f77287906631 /src/thread.c
parent86e6ed8521564105a42ae52851b6bff7e3a12a94 (diff)
downloademacs-f7fdaea4c0a2f4285d974a2870c4f6b465b40500.tar.gz
A better solution for bug#29347
* src/thread.c (really_call_select): Don't try to take the global lock if the same thread is already holding it. (Bug#29347)
Diffstat (limited to 'src/thread.c')
-rw-r--r--src/thread.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/thread.c b/src/thread.c
index 9e799ce47d4..dd466818ef9 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -97,12 +97,7 @@ post_acquire_global_lock (struct thread_state *self)
static void
acquire_global_lock (struct thread_state *self)
{
- /* If some Lisp was interrupted by C-g while inside pselect, the
- signal handler could have called maybe_reacquire_global_lock, in
- which case we are already holding the lock and shouldn't try
- taking it again, or else we will hang forever. */
- if (!(self && !self->not_holding_lock))
- sys_mutex_lock (&global_lock);
+ sys_mutex_lock (&global_lock);
post_acquire_global_lock (self);
}
@@ -578,8 +573,15 @@ really_call_select (void *arg)
sa->timeout, sa->sigmask);
block_interrupt_signal (&oldset);
- acquire_global_lock (self);
- self->not_holding_lock = 0;
+ /* If we were interrupted by C-g while inside sa->func above, the
+ signal handler could have called maybe_reacquire_global_lock, in
+ which case we are already holding the lock and shouldn't try
+ taking it again, or else we will hang forever. */
+ if (self->not_holding_lock)
+ {
+ acquire_global_lock (self);
+ self->not_holding_lock = 0;
+ }
restore_signal_mask (&oldset);
}