Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem of rest protocol PR #352 #396

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions protocol/rest/rest_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ type RestProtocol struct {
func NewRestProtocol() *RestProtocol {
return &RestProtocol{
BaseProtocol: protocol.NewBaseProtocol(),
serverMap: make(map[string]rest_interface.RestServer),
clientMap: make(map[rest_interface.RestOptions]rest_interface.RestClient),
serverMap: make(map[string]rest_interface.RestServer, 8),
clientMap: make(map[rest_interface.RestOptions]rest_interface.RestClient, 8),
}
}

Expand Down Expand Up @@ -105,13 +105,13 @@ func (rp *RestProtocol) getServer(url common.URL, serverType string) rest_interf
panic("[RestProtocol]" + url.ServiceKey() + "is not existing")
}
rp.serverLock.Lock()
defer rp.serverLock.Unlock()
restServer, ok = rp.serverMap[url.Location]
if !ok {
restServer = extension.GetNewRestServer(serverType)
restServer.Start(url)
rp.serverMap[url.Location] = restServer
}
rp.serverLock.Unlock()
return restServer
}

Expand All @@ -121,12 +121,12 @@ func (rp *RestProtocol) getClient(restOptions rest_interface.RestOptions, client
return restClient
}
rp.clientLock.Lock()
defer rp.clientLock.Unlock()
restClient, ok = rp.clientMap[restOptions]
if !ok {
restClient = extension.GetNewRestClient(clientType, &restOptions)
rp.clientMap[restOptions] = restClient
}
rp.clientLock.Unlock()
return restClient
}

Expand Down