]> Cypherpunks repositories - gostls13.git/commitdiff
Avoid race condition. Following the left to right rule,
authorIan Lance Taylor <iant@golang.org>
Tue, 7 Jul 2009 17:15:01 +0000 (10:15 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 7 Jul 2009 17:15:01 +0000 (10:15 -0700)
s.output.Data() was being retrieved before the synchronization
point, which meant that it could be retrieved before the
goroutine wrote it.  Using gccgo this caused random errors.

R=gri
DELTA=2  (1 added, 0 deleted, 1 changed)
OCL=31046
CL=31267

src/pkg/datafmt/datafmt.go

index 48c24e7264c4ea1e5e00aaeba9e908404692f526..96dc1d743d474569b91accc57d355d1765abac70 100644 (file)
@@ -745,7 +745,8 @@ func (f Format) Eval(env Environment, args ...) ([]byte, os.Error) {
                errors <- nil;  // no errors
        }();
 
-       return s.output.Data(), <- errors;
+       err := <- errors;
+       return s.output.Data(), err;
 }