summaryrefslogtreecommitdiff
path: root/src/pkg/net
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2012-08-30 20:32:32 +0400
committerDmitriy Vyukov <dvyukov@google.com>2012-08-30 20:32:32 +0400
commit5447f9dd795490009bd2bf8abc1b90c487e98ec4 (patch)
tree85298cbce1fbb4f412807436ed75d75a8d089b7a /src/pkg/net
parentde20d2ca048f46ec8b5dc69c08cadddac22435a7 (diff)
downloadgo-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.go6
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