@@ -163,16 +163,20 @@ CAMLexport void (*caml_leave_blocking_section_hook)(void) =
163163
164164CAMLexport void caml_enter_blocking_section (void )
165165{
166- while (1 ){
166+ caml_domain_state * domain = Caml_state ;
167+ while (1 ) {
167168 /* Process all pending signals now */
168- caml_raise_if_exception (caml_process_pending_signals_exn ());
169+ if (Caml_check_gc_interrupt (domain )) {
170+ /* Some actions might remain after this, but it is no longer an
171+ external interrupt. */
172+ caml_set_action_pending (domain );
173+ caml_handle_gc_interrupt ();
174+ caml_raise_if_exception (caml_process_pending_signals_exn ());
175+ }
169176 caml_enter_blocking_section_hook ();
170- /* Check again for pending signals.
171- If none, done; otherwise, try again */
172- // FIXME: does this become very slow if a signal is recorded but
173- // is masked for everybody in capacity of running signals at this
174- // point?
175- if (!caml_check_pending_signals ()) break ;
177+ /* Check again if a signal arrived in the meanwhile. If none, done;
178+ otherwise, try again */
179+ if (!Caml_check_gc_external_interrupt (domain )) break ;
176180 caml_leave_blocking_section_hook ();
177181 }
178182}
@@ -301,7 +305,9 @@ void caml_request_minor_gc (void)
301305void caml_set_action_pending (caml_domain_state * dom_st )
302306{
303307 dom_st -> action_pending = 1 ;
304- atomic_store_rel (& dom_st -> young_limit , (uintnat )- 1 );
308+ /* Non-external interrupt */
309+ atomic_store_rel (& dom_st -> young_limit , (uintnat )dom_st -> young_end + 1 );
310+ CAMLassert (caml_check_gc_interrupt (dom_st ));
305311}
306312
307313CAMLexport int caml_check_pending_actions (void )
0 commit comments