mirror of
https://github.com/golang/go
synced 2024-11-22 14:54:46 -07:00
runtime: fix race condition between GC and setGCPercent
If first GC runs concurrently with setGCPercent, it can overwrite gcpercent value with default. R=golang-dev, iant CC=golang-dev https://golang.org/cl/10242047
This commit is contained in:
parent
4bb491b12e
commit
94dc963b55
@ -1974,7 +1974,10 @@ runtime·gc(int32 force)
|
||||
return;
|
||||
|
||||
if(gcpercent == GcpercentUnknown) { // first time through
|
||||
gcpercent = readgogc();
|
||||
runtime·lock(&runtime·mheap);
|
||||
if(gcpercent == GcpercentUnknown)
|
||||
gcpercent = readgogc();
|
||||
runtime·unlock(&runtime·mheap);
|
||||
|
||||
p = runtime·getenv("GOGCTRACE");
|
||||
if(p != nil)
|
||||
|
Loading…
Reference in New Issue
Block a user