]> granicus.if.org Git - gc/commitdiff
Explicitly unblock GC signals on GC initialization
authorIvan Maidanski <ivmai@mail.ru>
Thu, 22 Mar 2018 22:09:40 +0000 (01:09 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 22 Mar 2018 22:09:40 +0000 (01:09 +0300)
Issue #175 (bdgwc).

Note: NO_SIGNALS_UNBLOCK_IN_MAIN macro is to be defined manually to
turn off this feature (for a reason).

* include/private/gcconfig.h [GC_NO_PTHREAD_SIGMASK]
(NO_SIGNALS_UNBLOCK_IN_MAIN): New macro.
* pthread_stop_world.c [GC_PTHREADS && !GC_WIN32_THREADS
&& !GC_DARWIN_THREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2 && !NACL
&& !GC_OPENBSD_UTHREADS && !NO_SIGNALS_UNBLOCK_IN_MAIN]
(GC_unblock_gc_signals): Define.
* pthread_stop_world.c [GC_PTHREADS && !GC_WIN32_THREADS
&& !GC_DARWIN_THREADS && !SN_TARGET_ORBIS && !SN_TARGET_PSP2 && !NACL
&& !GC_OPENBSD_UTHREADS && !NO_SIGNALS_UNBLOCK_IN_MAIN] (GC_stop_init):
Call GC_unblock_gc_signals; add comment.

include/private/gcconfig.h
pthread_stop_world.c

index 408318c3654f9fddddf0b1598da74fe014584299..e382fbd660b96bc604c00cf47c153e4ea2845b16 100644 (file)
@@ -2975,6 +2975,10 @@ EXTERN_C_BEGIN
 # define GC_EXPLICIT_SIGNALS_UNBLOCK
 #endif
 
+#if !defined(NO_SIGNALS_UNBLOCK_IN_MAIN) && defined(GC_NO_PTHREAD_SIGMASK)
+# define NO_SIGNALS_UNBLOCK_IN_MAIN
+#endif
+
 #if !defined(NO_MARKER_SPECIAL_SIGMASK) \
     && (defined(NACL) || defined(GC_WIN32_PTHREADS))
   /* Either there is no pthread_sigmask(), or GC marker thread cannot   */
index 454eb4299b2aafea3914d871de2103bc7ee32e10..5b5956d36fcf7f38c4aa360e64010ff7c755e4cd 100644 (file)
@@ -186,7 +186,8 @@ GC_API int GC_CALL GC_get_thr_restart_signal(void)
             ? GC_sig_thr_restart : SIG_THR_RESTART;
 }
 
-#ifdef GC_EXPLICIT_SIGNALS_UNBLOCK
+#if defined(GC_EXPLICIT_SIGNALS_UNBLOCK) \
+    || !defined(NO_SIGNALS_UNBLOCK_IN_MAIN)
   /* Some targets (e.g., Solaris) might require this to be called when  */
   /* doing thread registering from the thread destructor.               */
   GC_INNER void GC_unblock_gc_signals(void)
@@ -1198,6 +1199,10 @@ GC_INNER void GC_stop_init(void)
     if (GC_retry_signals) {
       GC_COND_LOG_PRINTF("Will retry suspend signal if necessary\n");
     }
+#   ifndef NO_SIGNALS_UNBLOCK_IN_MAIN
+      /* Explicitly unblock the signals once before new threads creation. */
+      GC_unblock_gc_signals();
+#   endif
 # endif /* !GC_OPENBSD_UTHREADS && !NACL */
 }