fix: use clientsLocker mutex

This commit is contained in:
James Houlahan 2020-04-08 13:11:05 +02:00
parent abca7284dd
commit d787d8b223
1 changed files with 6 additions and 0 deletions

View File

@ -108,6 +108,9 @@ func (cm *ClientManager) GetRoundTripper() (rt http.RoundTripper) {
// GetClient returns a client for the given userID.
// If the client does not exist already, it is created.
func (cm *ClientManager) GetClient(userID string) Client {
cm.clientsLocker.Lock()
defer cm.clientsLocker.Unlock()
if client, ok := cm.clients[userID]; ok {
return client
}
@ -119,6 +122,9 @@ func (cm *ClientManager) GetClient(userID string) Client {
// GetAnonymousClient returns an anonymous client. It replaces any anonymous client that was already created.
func (cm *ClientManager) GetAnonymousClient() Client {
cm.clientsLocker.Lock()
defer cm.clientsLocker.Unlock()
if client, ok := cm.clients[""]; ok {
client.DeleteAuth()
}