From eca0c18730fd1521c1995d58ad1422adb8ee6f8a Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 13 Mar 2015 12:21:06 -0600 Subject: [PATCH] fix at-exit close handling for non-main place This bug has been causing problems since the change to the `math` library to register mpfr_free_cache() only once per place. --- racket/src/racket/src/thread.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/racket/src/racket/src/thread.c b/racket/src/racket/src/thread.c index a71aecd5bd..1014d4d720 100644 --- a/racket/src/racket/src/thread.c +++ b/racket/src/racket/src/thread.c @@ -1846,15 +1846,17 @@ void scheme_add_atexit_closer(Scheme_Exit_Closer_Func f) # define RUNNING_IN_ORIGINAL_PLACE 1 #endif - if (!cust_closers && RUNNING_IN_ORIGINAL_PLACE) { - if (replacement_at_exit) { - replacement_at_exit(do_run_atexit_closers_on_all); - } else { + if (!cust_closers) { + if (RUNNING_IN_ORIGINAL_PLACE) { + if (replacement_at_exit) { + replacement_at_exit(do_run_atexit_closers_on_all); + } else { #ifdef USE_ON_EXIT_FOR_ATEXIT - on_exit(do_run_atexit_closers_on_all, NULL); + on_exit(do_run_atexit_closers_on_all, NULL); #else - atexit(do_run_atexit_closers_on_all); + atexit(do_run_atexit_closers_on_all); #endif + } } REGISTER_SO(cust_closers);