From: simonmar Date: Mon, 15 Nov 1999 14:14:43 +0000 (+0000) Subject: [project @ 1999-11-15 14:14:43 by simonmar] X-Git-Tag: Approximately_9120_patches~5555 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=c57411aa9d51f0e66e1c4d7ae1bc32a959c7910c;p=ghc-hetmet.git [project @ 1999-11-15 14:14:43 by simonmar] Fix queue corruption bug in unblocking of threads blocked on I/O. --- 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; }