Add lock while releasing session

Solve the problem of SessionRead failure while ReleaseSession is in progress
This commit is contained in:
HANG ZHOU 2017-12-05 16:18:56 +08:00 committed by GitHub
parent c5118e9535
commit ed73bdcfab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -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)