]> granicus.if.org Git - gc/commitdiff
Fix GC_restart_handler to preserve errno if needed
authorIvan Maidanski <ivmai@mail.ru>
Tue, 10 Jan 2012 17:00:59 +0000 (21:00 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 16 Jan 2012 12:37:05 +0000 (16:37 +0400)
* pthread_stop_world.c (GC_restart_handler): Preserve errno value in
case of sem_post or GC_log_printf invocation inside.

pthread_stop_world.c

index fa4e4d5f41e06fb25e0d02dce8cee3a47d44a9e4..811cfb5a86697721c5b347a786b31d5924e52897 100644 (file)
@@ -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 */