Sfoglia il codice sorgente

protext all access to _logstream with the existing mutex

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
Matthieu Gallien 2 anni fa
parent
commit
c2d72109b6
1 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. 3 1
      src/libsync/logger.cpp

+ 3 - 1
src/libsync/logger.cpp

@@ -118,7 +118,6 @@ void Logger::doLog(QtMsgType type, const QMessageLogContext &ctx, const QString
     cout << msg << endl;
 #endif
     {
-        QMutexLocker lock(&_mutex);
         if (_logFile.size() >= MaxLogSizeBytes) {
             close();
             enterNextLogFile();
@@ -127,6 +126,8 @@ void Logger::doLog(QtMsgType type, const QMessageLogContext &ctx, const QString
         _crashLogIndex = (_crashLogIndex + 1) % CrashLogSize;
         _crashLog[_crashLogIndex] = msg;
 
+        QMutexLocker lock(&_mutex);
+
         if (_logstream) {
             (*_logstream) << msg << Qt::endl;
             if (_doFileFlush)
@@ -145,6 +146,7 @@ void Logger::doLog(QtMsgType type, const QMessageLogContext &ctx, const QString
 
 void Logger::close()
 {
+    QMutexLocker lock(&_mutex);
     dumpCrashLog();
     if (_logstream)
     {