From edd09ea7e5ec828b503d2e1aafd40afa350ae7d0 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Mon, 18 Jan 2010 23:22:06 +0100 Subject: [PATCH] PROCESS-JOIN would fail when called while a thread was being started. --- src/CHANGELOG | 2 ++ src/c/threads.d | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/CHANGELOG b/src/CHANGELOG index 80390ff65..1f96c9915 100755 --- a/src/CHANGELOG +++ b/src/CHANGELOG @@ -15,6 +15,8 @@ ECL 10.1.1: - PROCESS-JOIN was exported from the wrong package. + - PROCESS-JOIN would fail when called while a thread was being started. + ;;; Local Variables: *** ;;; mode:text *** ;;; fill-column:79 *** diff --git a/src/c/threads.d b/src/c/threads.d index 478f1b642..c606aa3c1 100644 --- a/src/c/threads.d +++ b/src/c/threads.d @@ -141,6 +141,7 @@ thread_entry_point(void *arg) cl_object process = (cl_object)arg; cl_env_ptr env; + process->process.active = 2; #ifndef ECL_WINDOWS_THREADS pthread_cleanup_push(thread_cleanup, (void *)process); #endif @@ -434,9 +435,11 @@ mp_process_join(cl_object process) { assert_type_process(process); /* We only wait for threads that we have created */ - if (process->process.active != 1) { + if (process->process.active) { cl_object l = process->process.exit_lock; if (!Null(l)) { + while (process->process.active != 1) + cl_sleep(MAKE_FIXNUM(0)); l = mp_get_lock(1, l); if (Null(l)) { FEerror("MP:PROCESS-JOIN: Error when "