diff options
author | Dmitriy Vyukov <dvyukov@google.com> | 2012-08-30 20:32:32 +0400 |
---|---|---|
committer | Dmitriy Vyukov <dvyukov@google.com> | 2012-08-30 20:32:32 +0400 |
commit | 5447f9dd795490009bd2bf8abc1b90c487e98ec4 (patch) | |
tree | 85298cbce1fbb4f412807436ed75d75a8d089b7a /src/pkg/net | |
parent | de20d2ca048f46ec8b5dc69c08cadddac22435a7 (diff) | |
download | go-5447f9dd795490009bd2bf8abc1b90c487e98ec4.tar.gz |
net/rpc: protect serviceMap with RWMutex
R=r, r
CC=golang-dev
http://codereview.appspot.com/6494044
Diffstat (limited to 'src/pkg/net')
-rw-r--r-- | src/pkg/net/rpc/server.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/pkg/net/rpc/server.go b/src/pkg/net/rpc/server.go index 9e0aa0ce2..e5282202c 100644 --- a/src/pkg/net/rpc/server.go +++ b/src/pkg/net/rpc/server.go @@ -182,7 +182,7 @@ type Response struct { // Server represents an RPC Server. type Server struct { - mu sync.Mutex // protects the serviceMap + mu sync.RWMutex // protects the serviceMap serviceMap map[string]*service reqLock sync.Mutex // protects freeReq freeReq *Request @@ -539,9 +539,9 @@ func (server *Server) readRequestHeader(codec ServerCodec) (service *service, mt return } // Look up the request. - server.mu.Lock() + server.mu.RLock() service = server.serviceMap[serviceMethod[0]] - server.mu.Unlock() + server.mu.RUnlock() if service == nil { err = errors.New("rpc: can't find service " + req.ServiceMethod) return |