]> 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>
Wed, 11 Jan 2012 14:51:58 +0000 (18:51 +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 ebe010ecee08ca38f531e9da9fb33dab6516f21e..2632684290414850740935aa7930e0f7b95d5eb3 100644 (file)
@@ -270,6 +270,10 @@ STATIC void GC_suspend_handler_inner(ptr_t sig_arg,
 
 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
@@ -287,6 +291,9 @@ STATIC void GC_restart_handler(int sig)
 # ifdef DEBUG_THREADS
     GC_log_printf("In GC_restart_handler for %p\n", (void *)pthread_self());
 # endif
+# if defined(DEBUG_THREADS) || defined(GC_NETBSD_THREADS_WORKAROUND)
+    errno = old_errno;
+# endif
 }
 
 #endif /* !GC_OPENBSD_THREADS && !NACL */