mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
logger: unlock the mutex for fsync & call fsync only when backend is running
- fsync can be a long blocking operation, so we need to make sure the main logger thread does not block during this time, when it tries to aquire the mutex - fixes calling fsync on an invalid file descriptor
This commit is contained in:
@@ -257,8 +257,10 @@ void LogWriterFile::run()
|
||||
buffer.close_file();
|
||||
}
|
||||
|
||||
} else if (call_fsync) {
|
||||
} else if (call_fsync && buffer._should_run) {
|
||||
pthread_mutex_unlock(&_mtx);
|
||||
buffer.fsync();
|
||||
pthread_mutex_lock(&_mtx);
|
||||
|
||||
} else if (available == 0 && !buffer._should_run) {
|
||||
buffer.close_file();
|
||||
|
||||
Reference in New Issue
Block a user