mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-31 07:30:32 +00:00
fix(server): close old log file after swap in SetOutputFile
Swap outputFile before closing the previous file handle, so no read of outputFile can observe a dangling pointer to a closed file. Also wrap the file-open in the mutex (already done) for atomicity of the entire file rotation sequence.
This commit is contained in:
parent
21b363c2bb
commit
172aeb2a6f
@ -173,10 +173,11 @@ func SetOutputFile(path string) error {
|
||||
return err
|
||||
}
|
||||
SetOutput(f)
|
||||
if outputFile != nil {
|
||||
_ = outputFile.Close()
|
||||
}
|
||||
prev := outputFile
|
||||
outputFile = f
|
||||
if prev != nil {
|
||||
_ = prev.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user