From b59a1c4c470ec7fe0f0a12e13d7b32e4f23c97f8 Mon Sep 17 00:00:00 2001 From: jgarcia Date: Sat, 24 Jun 2006 12:41:39 +0000 Subject: [PATCH] cl_shutdown() and cl_boot() may be called multiple times. cl_shutdown() empties the list of hooks when they are invoked. --- src/CHANGELOG | 2 ++ src/c/main.d | 30 +++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/CHANGELOG b/src/CHANGELOG index b97f1b753..1f509cea1 100644 --- a/src/CHANGELOG +++ b/src/CHANGELOG @@ -265,6 +265,8 @@ ECL 0.9i - ecl_listen_stream (used in LISTEN or READ-CHAR-NO-HANG) now returns the correct value when applied on a CLOS stream (M. Goffioul) + - Calling cl_shutdown() or cl_boot() multiple times is now safe. + * Documentation: - The HTML manuals now use CSS for a more appealing look. diff --git a/src/c/main.d b/src/c/main.d index 1bfefcf0c..be348154a 100644 --- a/src/c/main.d +++ b/src/c/main.d @@ -130,19 +130,23 @@ static const struct { int cl_shutdown(void) { - cl_object l = SYM_VAL(@'si::*exit-hooks*'); - cl_object form = cl_list(2, @'funcall', Cnil); - while (CONSP(l)) { - CADR(form) = CAR(l); - si_safe_eval(3, form, Cnil, OBJNULL); - l = CDR(l); - } + if (ecl_booted > 0) { + cl_object l = SYM_VAL(@'si::*exit-hooks*'); + cl_object form = cl_list(2, @'funcall', Cnil); + while (CONSP(l)) { + CADR(form) = CAR(l); + si_safe_eval(3, form, Cnil, OBJNULL); + l = CDR(l); + ECL_SET(@'si::*exit-hooks*', l); + } #ifdef ENABLE_DLOPEN - ecl_library_close_all(); + ecl_library_close_all(); #endif #ifdef TCP - ecl_tcp_close_all(); + ecl_tcp_close_all(); #endif + } + ecl_booted = -1; return 1; } @@ -153,6 +157,14 @@ cl_boot(int argc, char **argv) cl_object features; int i; + if (ecl_booted) { + if (ecl_booted < 0) { + /* We have called cl_shutdown and want to use ECL again. */ + ecl_booted = 1; + } + return; + } + #if !defined(GBC_BOEHM) setbuf(stdin, stdin_buf); setbuf(stdout, stdout_buf);