1
0
의 미러 https://github.com/astaxie/beego.git synced 2025-07-12 10:31:03 +00:00

static file map race bug fixed

This commit is contained in:
JessonChan
2016-03-04 10:15:59 +08:00
부모 4b99e41880
커밋 226e54e0d8

파일 보기

@ -93,12 +93,14 @@ type serveContentHolder struct {
var (
staticFileMap = make(map[string]*serveContentHolder)
mapLock sync.Mutex
mapLock sync.RWMutex
)
func openFile(filePath string, fi os.FileInfo, acceptEncoding string) (bool, string, *serveContentHolder, error) {
mapKey := acceptEncoding + ":" + filePath
mapLock.RLock()
mapFile, _ := staticFileMap[mapKey]
mapLock.RUnlock()
if isOk(mapFile, fi) {
return mapFile.encoding != "", mapFile.encoding, mapFile, nil
}