0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

markdown: fix race in accessing map

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov 2015-09-11 08:34:52 -07:00
parent dc4a5ae1fd
commit a5128da67a
2 changed files with 6 additions and 1 deletions

View file

@ -126,8 +126,11 @@ func (md Markdown) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
}
}
cfg.RLock()
filepath, ok := cfg.StaticFiles[fpath]
cfg.RUnlock()
// if static site is generated, attempt to use it
if filepath, ok := cfg.StaticFiles[fpath]; ok {
if ok {
if fs1, err := os.Stat(filepath); err == nil {
// if markdown has not been modified since static page
// generation, serve the static page

View file

@ -153,7 +153,9 @@ func (md Markdown) generatePage(c *Config, requestPath string, content []byte) e
return err
}
c.Lock()
c.StaticFiles[requestPath] = filePath
c.Unlock()
}
return nil