Fix concurrent map issue accessing Configuration.envVars

This commit is contained in:
Steve Streeting 2016-04-05 14:29:45 +01:00
parent 825cf2e708
commit 95272fef40

@ -50,6 +50,7 @@ type Configuration struct {
redirectingHttpClient *http.Client
ntlmSession ntlm.ClientSession
envVars map[string]string
envVarsMutex sync.Mutex
isTracingHttp bool
isDebuggingHttp bool
isLoggingStats bool
@ -78,6 +79,9 @@ func NewConfig() *Configuration {
}
func (c *Configuration) Getenv(key string) string {
c.envVarsMutex.Lock()
defer c.envVarsMutex.Unlock()
if i, ok := c.envVars[key]; ok {
return i
}
@ -88,6 +92,9 @@ func (c *Configuration) Getenv(key string) string {
}
func (c *Configuration) Setenv(key, value string) error {
c.envVarsMutex.Lock()
defer c.envVarsMutex.Unlock()
// Check see if we have this in our cache, if so update it
if _, ok := c.envVars[key]; ok {
c.envVars[key] = value