[Libreoffice-commits] online.git: 2 commits - loolwsd/Log.cpp loolwsd/LOOLKit.cpp

Tor Lillqvist tml at collabora.com
Tue Sep 20 10:56:22 UTC 2016


 loolwsd/LOOLKit.cpp |    2 +-
 loolwsd/Log.cpp     |    7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 90c7b553edacc2425279d5bc21c5cb970361cdb4
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Sep 20 13:07:29 2016 +0300

    Don't erase the CallbackDescriptor record before turning off callbacks
    
    Seems to fix the deadlock problem, or at least makes it very much
    rarer. (I am not entirely certain that a callback might not be in
    progress already (in another thread) when we turn off callbacks, and
    in that case the callback might still then access freed memory?)

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 02919e6..4f1f448 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1000,9 +1000,9 @@ private:
         std::unique_lock<std::mutex> lock(_loKitDocument->getLock());
 
         const auto viewId = session.getViewId();
-        _viewIdToCallbackDescr.erase(viewId);
         _loKitDocument->setView(viewId);
         _loKitDocument->registerCallback(nullptr, nullptr);
+        _viewIdToCallbackDescr.erase(viewId);
         _loKitDocument->destroyView(viewId);
         Log::debug("Destroyed view " + std::to_string(viewId));
     }
commit 8207412c020284b458eddeeb3501f8bb20ccb09e
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Sep 20 12:58:50 2016 +0300

    Poco::Thread::current() is not reliable for logging
    
    It can return null for no obvious reason, leading to misleading
    logging where the same thread is identified as numer zero at one place
    and non-zero at another. So use the actual Linux thread id in logging.
    
    Sure, thread ids are somewhat less convenient, as they are larger
    numbers, from the same number space as process ids.

diff --git a/loolwsd/Log.cpp b/loolwsd/Log.cpp
index 0c327df..c146af5 100644
--- a/loolwsd/Log.cpp
+++ b/loolwsd/Log.cpp
@@ -15,6 +15,9 @@
 #include <sstream>
 #include <string>
 
+#include <sys/syscall.h>
+#include <unistd.h>
+
 #include <Poco/ConsoleChannel.h>
 #include <Poco/FileChannel.h>
 #include <Poco/FormattingChannel.h>
@@ -88,8 +91,8 @@ namespace Log
         const char *appName = (Source.inited ? Source.id.c_str() : "<shutdown>");
         assert(strlen(appName) + 32 + 28 < 1024 - 1);
 
-        snprintf(buffer, 4095, "%s-%.2d %d:%.2d:%.2d.%.6d [ %s ] %s  ", appName,
-                 (Poco::Thread::current() ? Poco::Thread::current()->id() : 0),
+        snprintf(buffer, 4095, "%s-%.04lu %d:%.2d:%.2d.%.6d [ %s ] %s  ", appName,
+                 syscall(SYS_gettid),
                  (int)hours, (int)minutes, (int)seconds, (int)usec,
                  procName, level);
     }


More information about the Libreoffice-commits mailing list