From c57411aa9d51f0e66e1c4d7ae1bc32a959c7910c Mon Sep 17 00:00:00 2001 From: simonmar Date: Mon, 15 Nov 1999 14:14:43 +0000 Subject: [PATCH] [project @ 1999-11-15 14:14:43 by simonmar] Fix queue corruption bug in unblocking of threads blocked on I/O. --- ghc/rts/Schedule.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c index c35d098..32e18b4 100644 --- a/ghc/rts/Schedule.c +++ b/ghc/rts/Schedule.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Schedule.c,v 1.32 1999/11/11 17:19:15 simonmar Exp $ + * $Id: Schedule.c,v 1.33 1999/11/15 14:14:43 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -1246,13 +1246,20 @@ unblockThread(StgTSO *tso) case BlockedOnRead: case BlockedOnWrite: { - last = &blocked_queue_hd; + StgTSO *prev = NULL; for (t = blocked_queue_hd; t != END_TSO_QUEUE; - last = &t->link, t = t->link) { + prev = t, t = t->link) { if (t == tso) { - *last = tso->link; - if (blocked_queue_tl == t) { - blocked_queue_tl = tso->link; + if (prev == NULL) { + blocked_queue_hd = t->link; + if (blocked_queue_tl == t) { + blocked_queue_tl = END_TSO_QUEUE; + } + } else { + prev->link = t->link; + if (blocked_queue_tl == t) { + blocked_queue_tl = prev; + } } goto done; } -- 1.7.10.4