From 9e9163f4eacedb478c1795c135208e246ecf4889 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Tue, 28 May 1996 14:50:38 +0000 Subject: [PATCH] Ne pas rescheduler a l'interieur d'un callback. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@851 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- otherlibs/threads/scheduler.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/otherlibs/threads/scheduler.c b/otherlibs/threads/scheduler.c index 5cabc919f..2d90411b0 100644 --- a/otherlibs/threads/scheduler.c +++ b/otherlibs/threads/scheduler.c @@ -231,6 +231,8 @@ static double timeofday() #define END_FOREACH(x) } while (x != curr_thread) static value alloc_process_status(); +extern int callback_depth; + static value schedule_thread() { thread_t run_thread, th; @@ -238,6 +240,12 @@ static value schedule_thread() double delay, now; int need_select, need_wait; + /* Don't allow preemption during a callback */ + if (callback_depth > 0) { + if (curr_thread->status != RUNNABLE) + invalid_argument("Thread: deadlock in callback"); + return curr_thread->retval; + } /* Save the status of the current thread */ curr_thread->stack_low = stack_low; curr_thread->stack_high = stack_high;