[Libreoffice-commits] online.git: loolwsd/LOOLSession.cpp loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp

Henry Castro hcastro at collabora.com
Wed Aug 5 17:24:41 PDT 2015


 loolwsd/LOOLSession.cpp |   12 +++++++++++-
 loolwsd/LOOLWSD.cpp     |    3 ++-
 loolwsd/LOOLWSD.hpp     |    1 +
 3 files changed, 14 insertions(+), 2 deletions(-)

New commits:
commit ee928f9af1bd05752604a10af22e0c4e9180dec7
Author: Henry Castro <hcastro at collabora.com>
Date:   Wed Aug 5 20:20:05 2015 -0400

    loolwsd: create lokit process id logs
    
    Also, when used with --test option, create lokit PID log
    so it is attached to the debugger.
    
    gdb loolwsd $(cat /tmp/lokit.pid)

diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 10e299f..f7439c5 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -46,6 +46,7 @@
 #include <Poco/Net/NetException.h>
 #include <Poco/Net/DialogSocket.h>
 #include <Poco/Net/SocketAddress.h>
+#include <Poco/FileStream.h>
 
 #include "LOKitHelper.hpp"
 #include "LOOLProtocol.hpp"
@@ -223,13 +224,14 @@ bool MasterProcessSession::handleInput(const char *buffer, int length)
             sendTextFrame("error: cmd=child kind=invalid");
             return false;
         }
-        if (tokens.count() != 2)
+        if (tokens.count() != 3)
         {
             sendTextFrame("error: cmd=child kind=syntax");
             return false;
         }
 
         UInt64 childId = std::stoull(tokens[1]);
+        Process::PID pidChild = std::stoull(tokens[2]);
 
         std::unique_lock<std::mutex> lock(_availableChildSessionMutex);
         _availableChildSessions.insert(shared_from_this());
@@ -237,6 +239,14 @@ bool MasterProcessSession::handleInput(const char *buffer, int length)
         _childId = childId;
         lock.unlock();
         _availableChildSessionCV.notify_one();
+
+        // log first lokit child pid information
+        if ( LOOLWSD::doTest )
+        {
+            Poco::FileOutputStream filePID(LOOLWSD::LOKIT_PIDLOG);
+            if (filePID.good())
+                filePID << pidChild;
+        }
     }
     else if (_kind == Kind::ToPrisoner)
     {
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 6d640d6..3d4869e 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -433,6 +433,7 @@ int LOOLWSD::uid = 0;
 #endif
 const std::string LOOLWSD::CHILD_URI = "/loolws/child/";
 const std::string LOOLWSD::PIDLOG = "/tmp/loolwsd.pid";
+const std::string LOOLWSD::LOKIT_PIDLOG = "/tmp/lokit.pid";
 
 LOOLWSD::LOOLWSD() :
     _childId(0)
@@ -758,7 +759,7 @@ void LOOLWSD::componentMain()
 
         ws->setReceiveTimeout(0);
 
-        std::string hello("child " + std::to_string(_childId));
+        std::string hello("child " + std::to_string(_childId) + " " + std::to_string(Process::id()));
         session->sendTextFrame(hello);
 
         tsqueue<std::string> queue;
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index 494fd8c..aa419c6 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -48,6 +48,7 @@ public:
     static const int MAINTENANCE_INTERVAL = 1;
     static const std::string CHILD_URI;
     static const std::string PIDLOG;
+    static const std::string LOKIT_PIDLOG;
 
 protected:
     void initialize(Poco::Util::Application& self) override;


More information about the Libreoffice-commits mailing list