From a32e442360447232315bd224e3358064da09bc4d Mon Sep 17 00:00:00 2001 From: crusader Date: Thu, 2 Nov 2017 19:41:51 +0900 Subject: [PATCH] ing --- service_map.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/service_map.go b/service_map.go index 8cf122a..f867ec4 100644 --- a/service_map.go +++ b/service_map.go @@ -59,7 +59,7 @@ type serviceMap struct { } // register adds a new service using reflection to extract its methods. -func (m *serviceMap) register(rcvr interface{}, name string) error { +func (sm *serviceMap) register(rcvr interface{}, name string) error { // Setup service. s := &service{ name: name, @@ -139,14 +139,14 @@ Loop: return fmt.Errorf("rpc: %q has no exported methods of suitable type", s.name) } // Add to the map. - m.mutex.Lock() - defer m.mutex.Unlock() - if m.services == nil { - m.services = make(map[string]*service) - } else if _, ok := m.services[s.name]; ok { + sm.mutex.Lock() + defer sm.mutex.Unlock() + if sm.services == nil { + sm.services = make(map[string]*service) + } else if _, ok := sm.services[s.name]; ok { return fmt.Errorf("rpc: service already defined: %q", s.name) } - m.services[s.name] = s + sm.services[s.name] = s return nil } @@ -170,15 +170,15 @@ func validateType(t reflect.Type) (rt reflect.Type, rv reflect.Value, err error) // get returns a registered service given a method name. // // The method name uses a dotted notation as in "Service.Method". -func (m *serviceMap) get(method string) (*service, *serviceMethod, error) { +func (sm *serviceMap) get(method string) (*service, *serviceMethod, error) { parts := strings.Split(method, ".") if len(parts) != 2 { err := fmt.Errorf("rpc: service/method request ill-formed: %q", method) return nil, nil, err } - m.mutex.Lock() - service := m.services[parts[0]] - m.mutex.Unlock() + sm.mutex.Lock() + service := sm.services[parts[0]] + sm.mutex.Unlock() if service == nil { err := fmt.Errorf("rpc: can't find service %q", method) return nil, nil, err