summaryrefslogtreecommitdiff
path: root/pthread_stop_world.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-01-10 18:00:59 +0100
committerIvan Maidanski <ivmai@mail.ru>2012-01-16 13:37:05 +0100
commit8e7acd91f5bdb5cff78765303571af6f971bc9f2 (patch)
treedec30963de120f2b066a72fc8c92ecc046dc8b40 /pthread_stop_world.c
parent9d0f9f157b284ad02201866e10c57c7f442a7e8e (diff)
Fix GC_restart_handler to preserve errno if needed
* pthread_stop_world.c (GC_restart_handler): Preserve errno value in case of sem_post or GC_log_printf invocation inside.
Diffstat (limited to 'pthread_stop_world.c')
-rw-r--r--pthread_stop_world.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/pthread_stop_world.c b/pthread_stop_world.c
index fa4e4d5..811cfb5 100644
--- a/pthread_stop_world.c
+++ b/pthread_stop_world.c
@@ -271,6 +271,10 @@ STATIC void GC_suspend_handler_inner(ptr_t sig_arg, void *context)
STATIC void GC_restart_handler(int sig)
{
+# if defined(DEBUG_THREADS) || defined(GC_NETBSD_THREADS_WORKAROUND)
+ int old_errno = errno; /* Preserve errno value. */
+# endif
+
if (sig != SIG_THR_RESTART) ABORT("Bad signal in suspend_handler");
# ifdef GC_NETBSD_THREADS_WORKAROUND
@@ -289,6 +293,9 @@ STATIC void GC_restart_handler(int sig)
GC_log_printf("In GC_restart_handler for 0x%x\n",
(unsigned)pthread_self());
# endif
+# if defined(DEBUG_THREADS) || defined(GC_NETBSD_THREADS_WORKAROUND)
+ errno = old_errno;
+# endif
}
#endif /* !GC_OPENBSD_THREADS && !NACL */