From ed73bdcfab4ca1a80da73cc3764d733cc1b2c8dd Mon Sep 17 00:00:00 2001 From: HANG ZHOU Date: Tue, 5 Dec 2017 16:18:56 +0800 Subject: [PATCH] Add lock while releasing session Solve the problem of SessionRead failure while ReleaseSession is in progress --- session/sess_file.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/session/sess_file.go b/session/sess_file.go index 3ca93d55..7be6ccad 100644 --- a/session/sess_file.go +++ b/session/sess_file.go @@ -78,6 +78,8 @@ func (fs *FileSessionStore) SessionID() string { // SessionRelease Write file session to local file with Gob string func (fs *FileSessionStore) SessionRelease(w http.ResponseWriter) { + filepder.lock.Lock() + defer filepder.lock.Unlock() b, err := EncodeGob(fs.values) if err != nil { SLogger.Println(err)