diff options
author | Russ Cox <rsc@golang.org> | 2010-04-07 20:38:02 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-04-07 20:38:02 -0700 |
commit | 0454e1cb72b5359386d28d040c16a27e7167b3bd (patch) | |
tree | 51430511952ff10fd5bc1bdeca4ed01052162759 /src/pkg/runtime | |
parent | 2a2bbf0e66de69cd3b5b39c0d10179371f67fc78 (diff) | |
download | golang-0454e1cb72b5359386d28d040c16a27e7167b3bd.tar.gz |
runtime: use explicit flag when finalizer goroutine is waiting
Avoids spurious wakeups during other sleeping by that goroutine.
Fixes issue 711.
R=r
CC=golang-dev
http://codereview.appspot.com/902041
Diffstat (limited to 'src/pkg/runtime')
-rw-r--r-- | src/pkg/runtime/mgc0.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pkg/runtime/mgc0.c b/src/pkg/runtime/mgc0.c index 8cde10209..f61c10c60 100644 --- a/src/pkg/runtime/mgc0.c +++ b/src/pkg/runtime/mgc0.c @@ -25,6 +25,8 @@ extern byte end[]; static G *fing; static Finalizer *finq; +static int32 fingwait; + static void sweepblock(byte*, int64, uint32*, int32); static void runfinq(void); @@ -306,8 +308,10 @@ gc(int32 force) // kick off or wake up goroutine to run queued finalizers if(fing == nil) fing = newproc1((byte*)runfinq, nil, 0, 0); - else if(fing->status == Gwaiting) + else if(fingwait) { ready(fing); + fingwait = 0; + } } m->locks--; @@ -340,6 +344,7 @@ runfinq(void) f = finq; finq = nil; if(f == nil) { + fingwait = 1; g->status = Gwaiting; gosched(); continue; |