From: Tom Tromey Date: Mon, 14 Sep 2009 22:30:43 +0000 (+0200) Subject: Release the current buffer when a thread exits. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cc64fa3c517cafc01be8179b46d58f2ff55e905d;p=emacs.git Release the current buffer when a thread exits. --- diff --git a/src/buffer.c b/src/buffer.c index 10378c3edf4..b20d0c42b6a 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1883,6 +1883,21 @@ acquire_buffer (char *end, void *nb) } } +/* Mark the thread's current buffer as not having an owner. This is + only ok to call when the thread is shutting down. The global lock + must be held when calling this function. */ + +void +release_buffer (thread) + struct thread_state *thread; +{ + if (!EQ (thread->m_current_buffer->owner, Qt)) + { + thread->m_current_buffer->owner = Qnil; + pthread_cond_broadcast (&buffer_cond); + } +} + /* Set the current buffer to B, and do not set windows_or_buffers_changed. This is used by redisplay. */ diff --git a/src/buffer.h b/src/buffer.h index 85c78893d4e..168cf1a65e8 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -854,6 +854,7 @@ extern void record_buffer P_ ((Lisp_Object)); extern void buffer_slot_type_mismatch P_ ((Lisp_Object, int)) NO_RETURN; extern void fix_overlays_before P_ ((struct buffer *, EMACS_INT, EMACS_INT)); extern void mmap_set_vars P_ ((int)); +extern void release_buffer P_ ((struct thread_state *)); /* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements. If NEXTP is non-NULL, return next overlay there. diff --git a/src/thread.c b/src/thread.c index 709e50e029a..3b6134aaeb4 100644 --- a/src/thread.c +++ b/src/thread.c @@ -181,6 +181,8 @@ run_thread (void *state) ; *iter = (*iter)->next_thread; + release_buffer (self); + xfree (self->m_specpdl); xfree (self);