修复锁释放错误问题
This commit is contained in:
parent
ce8f34cc81
commit
b3ce41b3b0
9
rpc.go
9
rpc.go
@ -105,7 +105,7 @@ func (r *request) GetServiceInfo(serviceFlag string) (*Service, error) {
|
||||
)
|
||||
|
||||
r.lock.RLock()
|
||||
defer r.lock.Unlock()
|
||||
defer r.lock.RUnlock()
|
||||
if serviceInfo, exist = r.serviceTable[serviceFlag]; !exist {
|
||||
return nil, errors.New(serviceFlag + " -> 服务不存在")
|
||||
}
|
||||
@ -176,8 +176,8 @@ func (r *request) GetServiceApi(serviceFlag string, apiFlag string) (*Service, *
|
||||
if serviceInfo, err = r.GetServiceInfo(serviceFlag); nil != err {
|
||||
return nil, nil, err
|
||||
}
|
||||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
r.lock.RLock()
|
||||
defer r.lock.RUnlock()
|
||||
if apiInfo, exist = serviceInfo.ApiTable[apiFlag]; !exist {
|
||||
return nil, nil, errors.New(serviceFlag + " : " + apiFlag + " -> api")
|
||||
}
|
||||
@ -311,6 +311,9 @@ func (r *request) getFullURLAndBody(serviceConfig *Service, apiConfig *Api, para
|
||||
case http.MethodDelete:
|
||||
body, _ = json.Marshal(parameter)
|
||||
}
|
||||
if nil == body {
|
||||
body = []byte("{}")
|
||||
}
|
||||
query := strings.Join(parameterPair, "&")
|
||||
if len(query) == 0 {
|
||||
return strings.ReplaceAll(fullURL, "//", "/"), body
|
||||
|
Loading…
Reference in New Issue
Block a user