mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-09 14:46:46 +02:00
Fix race condition in rotating file handler, fixes #709
This commit is contained in:
@@ -115,7 +115,11 @@ class RotatingFileHandler extends StreamHandler
|
|||||||
|
|
||||||
foreach (array_slice($logFiles, $this->maxFiles) as $file) {
|
foreach (array_slice($logFiles, $this->maxFiles) as $file) {
|
||||||
if (is_writable($file)) {
|
if (is_writable($file)) {
|
||||||
|
// suppress errors here as unlink() might fail if two processes
|
||||||
|
// are cleaning up/rotating at the same time
|
||||||
|
set_error_handler(function ($errno, $errstr, $errfile, $errline) {});
|
||||||
unlink($file);
|
unlink($file);
|
||||||
|
restore_error_handler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user