mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Fix spurious `throw from within critical section' errors
The crux of this problem was that the thread doing a throw, and so checking scm_i_critical_section_level, was different from the thread that was in a critical section. * libguile/async.h (scm_i_critical_section_level): Removed, replaced by per-thread critical_section_level. (SCM_CRITICAL_SECTION_START, SCM_CRITICAL_SECTION_END): Use per-thread critical_section_level. * libguile/continuations.c (scm_dynthrow): Check per-thread critical_section_level. * libguile/threads.c (guilify_self_1): Init per-thread critical_section_level. (scm_i_critical_section_level): Removed. * libguile/threads.h (scm_i_thread): New critical_section_level field. * libguile/throw.c (scm_ithrow): Check per-thread critical_section_level.
This commit is contained in:
parent
09d978f3f8
commit
87f30eda98
5 changed files with 9 additions and 8 deletions
|
@ -60,20 +60,18 @@ void scm_dynwind_unblock_asyncs (void);
|
|||
the manual.
|
||||
*/
|
||||
|
||||
/* Defined in threads.c. scm_i_critical_section_level is only used
|
||||
for error checking and will go away eventually. */
|
||||
/* Defined in threads.c. */
|
||||
extern scm_i_pthread_mutex_t scm_i_critical_section_mutex;
|
||||
extern int scm_i_critical_section_level;
|
||||
|
||||
#define SCM_CRITICAL_SECTION_START \
|
||||
do { \
|
||||
scm_i_pthread_mutex_lock (&scm_i_critical_section_mutex);\
|
||||
SCM_I_CURRENT_THREAD->block_asyncs++; \
|
||||
scm_i_critical_section_level++; \
|
||||
SCM_I_CURRENT_THREAD->critical_section_level++; \
|
||||
} while (0)
|
||||
#define SCM_CRITICAL_SECTION_END \
|
||||
do { \
|
||||
scm_i_critical_section_level--; \
|
||||
SCM_I_CURRENT_THREAD->critical_section_level--; \
|
||||
SCM_I_CURRENT_THREAD->block_asyncs--; \
|
||||
scm_i_pthread_mutex_unlock (&scm_i_critical_section_mutex); \
|
||||
scm_async_click (); \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue