mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 02:27:19 -04:00 
			
		
		
		
	Merge pull request #240 from LK4D4/fix_map_race
markdown: fix race in accessing map
This commit is contained in:
		
						commit
						7545755b00
					
				| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user