From 84a29fdd257e9647acd2e5af91ee37f817b93fcb Mon Sep 17 00:00:00 2001 From: simonmar Date: Tue, 5 Feb 2002 10:06:24 +0000 Subject: [PATCH] [project @ 2002-02-05 10:06:24 by simonmar] Fix bad bugs in deleteAllThreds: we were looping through the thread queues calling deleteThread() on each thread as we go, but calling deleteThread() has the side effect of removing the thread from the relevant queue, so we would end up breaking out of the loop after processing only a single thread. This may fix problems like "resurrectThreads: thread blocked in a strange way" seen after pressing ^C. Aside: we really shouldn't be using deleteThread() at all, since it doesn't give the thread a chance to clean up & release locks. To be well-behaved a program has to catch ^C itself at the moment. --- ghc/rts/Schedule.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c index ab008fd..d5e6936 100644 --- a/ghc/rts/Schedule.c +++ b/ghc/rts/Schedule.c @@ -1,5 +1,5 @@ /* --------------------------------------------------------------------------- - * $Id: Schedule.c,v 1.116 2002/02/04 20:56:53 sof Exp $ + * $Id: Schedule.c,v 1.117 2002/02/05 10:06:24 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -1452,15 +1452,18 @@ schedule( void ) void deleteAllThreads ( void ) { - StgTSO* t; + StgTSO* t, *next; IF_DEBUG(scheduler,sched_belch("deleting all threads")); - for (t = run_queue_hd; t != END_TSO_QUEUE; t = t->link) { + for (t = run_queue_hd; t != END_TSO_QUEUE; t = next) { + next = t->link; deleteThread(t); } - for (t = blocked_queue_hd; t != END_TSO_QUEUE; t = t->link) { + for (t = blocked_queue_hd; t != END_TSO_QUEUE; t = next) { + next = t->link; deleteThread(t); } - for (t = sleeping_queue; t != END_TSO_QUEUE; t = t->link) { + for (t = sleeping_queue; t != END_TSO_QUEUE; t = next) { + next = t->link; deleteThread(t); } run_queue_hd = run_queue_tl = END_TSO_QUEUE; -- 1.7.10.4