rpc: make Server.Mutex unexported

Currently it's possible to write:
var s rpc.Server
...
// reuse for my own purposes
s.Lock()
...
s.Unlock()
which is seemingly not intended.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4888049
This commit is contained in:
Dmitriy Vyukov 2011-08-16 18:34:56 +10:00 committed by Andrew Gerrand
parent 381f6a2eeb
commit 53573c02b8
2 changed files with 7 additions and 7 deletions

View file

@ -174,7 +174,7 @@ type Response struct {
// Server represents an RPC Server.
type Server struct {
sync.Mutex // protects the serviceMap
mu sync.Mutex // protects the serviceMap
serviceMap map[string]*service
reqLock sync.Mutex // protects freeReq
freeReq *Request
@ -226,8 +226,8 @@ func (server *Server) RegisterName(name string, rcvr interface{}) os.Error {
}
func (server *Server) register(rcvr interface{}, name string, useName bool) os.Error {
server.Lock()
defer server.Unlock()
server.mu.Lock()
defer server.mu.Unlock()
if server.serviceMap == nil {
server.serviceMap = make(map[string]*service)
}
@ -524,9 +524,9 @@ func (server *Server) readRequestHeader(codec ServerCodec) (service *service, mt
return
}
// Look up the request.
server.Lock()
server.mu.Lock()
service = server.serviceMap[serviceMethod[0]]
server.Unlock()
server.mu.Unlock()
if service == nil {
err = os.NewError("rpc: can't find service " + req.ServiceMethod)
return