Skip to content

Commit

Permalink
Merge pull request #3 from taosdata/enh/xftan/TD-31613
Browse files Browse the repository at this point in the history
fix: do not unlock the file when file locking fails
  • Loading branch information
huskar-t authored Aug 29, 2024
2 parents 359c236 + 7e68a85 commit 81b15b4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions rotatelogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ func (rl *RotateLogs) getWriterNolock(bailOnRotateFail, useGenerationalNames boo
baseFn := fileutil.GenerateFn(rl.pattern, rl.clock, rl.rotationTime)
var forceNewFile bool
filename := baseFn
fi, err := os.Stat(rl.curFn)
sizeRotation := false
fi, err := os.Stat(rl.curFn)
if err == nil && rl.rotationSize > 0 && rl.rotationSize <= fi.Size() {
forceNewFile = true
sizeRotation = true
Expand Down Expand Up @@ -332,7 +332,6 @@ func createLogFileAndLock(filename string, lockFilename string, appendFile bool)
// check file in use
err = LockFile(logFileHandle)
if err != nil {
UnlockFile(logFileHandle)
logFileHandle.Close()
return nil, nil, err
}
Expand Down

0 comments on commit 81b15b4

Please sign in to comment.