Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(211)

Unified Diff: src/pkg/encoding/gob/type.go

Issue 6637047: code review 6637047: encoding/gob: fix data race in Register (Closed)
Patch Set: diff -r 5a8c4552dd85 https://code.google.com/p/go/ Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/encoding/gob/encode.go ('k') | src/pkg/encoding/gob/type_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/encoding/gob/type.go
===================================================================
--- a/src/pkg/encoding/gob/type.go
+++ b/src/pkg/encoding/gob/type.go
@@ -712,6 +712,7 @@
}
var (
+ registerLock sync.RWMutex
nameToConcreteType = make(map[string]reflect.Type)
concreteTypeToName = make(map[reflect.Type]string)
)
@@ -723,6 +724,8 @@
// reserved for nil
panic("attempt to register empty name")
}
+ registerLock.Lock()
+ defer registerLock.Unlock()
ut := userType(reflect.TypeOf(value))
// Check for incompatible duplicates. The name must refer to the
// same user type, and vice versa.
« no previous file with comments | « src/pkg/encoding/gob/encode.go ('k') | src/pkg/encoding/gob/type_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b