[Libreoffice-commits] online.git: common/Log.cpp common/Session.hpp common/Util.cpp common/Util.hpp kit/ChildSession.cpp kit/ForKit.cpp kit/Kit.cpp net/Ssl.cpp tools/Config.cpp tools/KitClient.cpp wsd/Admin.cpp wsd/Admin.hpp wsd/AdminModel.cpp wsd/AdminModel.hpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp

Pranam Lashkari (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 29 12:28:15 UTC 2020


 common/Log.cpp         |    1 -
 common/Session.hpp     |    1 -
 common/Util.cpp        |    9 ++++-----
 common/Util.hpp        |   10 +++++-----
 kit/ChildSession.cpp   |    3 +--
 kit/ForKit.cpp         |   15 ++++++---------
 kit/Kit.cpp            |    1 -
 net/Ssl.cpp            |    2 +-
 tools/Config.cpp       |    1 +
 tools/KitClient.cpp    |    1 -
 wsd/Admin.cpp          |    4 ++--
 wsd/Admin.hpp          |    4 ++--
 wsd/AdminModel.cpp     |    5 ++---
 wsd/AdminModel.hpp     |   12 +++++-------
 wsd/DocumentBroker.hpp |    4 ++--
 wsd/LOOLWSD.cpp        |    3 +--
 wsd/LOOLWSD.hpp        |    7 +++----
 17 files changed, 35 insertions(+), 48 deletions(-)

New commits:
commit 8b349716eb58c1024f21627f78f8e66657e24bf2
Author:     Pranam Lashkari <lpranam at collabora.com>
AuthorDate: Tue Nov 26 18:45:38 2019 +0530
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Wed Apr 29 14:27:54 2020 +0200

    killpoco: removed Poco::Process completely
    
    Change-Id: Iba67abf9342c11517c69c1d94903bf4752aa87d6
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/83770
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/common/Log.cpp b/common/Log.cpp
index d96bd3f82..f9d0b5578 100644
--- a/common/Log.cpp
+++ b/common/Log.cpp
@@ -30,7 +30,6 @@
 #include <Poco/FileChannel.h>
 #include <Poco/FormattingChannel.h>
 #include <Poco/PatternFormatter.h>
-#include <Poco/Process.h>
 #include <Poco/SplitterChannel.h>
 #include <Poco/Timestamp.h>
 
diff --git a/common/Session.hpp b/common/Session.hpp
index 402223963..02a11fa23 100644
--- a/common/Session.hpp
+++ b/common/Session.hpp
@@ -19,7 +19,6 @@
 
 #include <Poco/Buffer.h>
 #include <Poco/Path.h>
-#include <Poco/Process.h>
 #include <Poco/Types.h>
 
 #include "Protocol.hpp"
diff --git a/common/Util.cpp b/common/Util.cpp
index e4d19adb1..0ae624983 100644
--- a/common/Util.cpp
+++ b/common/Util.cpp
@@ -52,7 +52,6 @@
 #include <Poco/JSON/JSON.h>
 #include <Poco/JSON/Object.h>
 #include <Poco/JSON/Parser.h>
-#include <Poco/Process.h>
 #include <Poco/RandomStream.h>
 #include <Poco/TemporaryFile.h>
 #include <Poco/Timestamp.h>
@@ -448,7 +447,7 @@ namespace Util
         return oss.str();
     }
 
-    size_t getMemoryUsagePSS(const Poco::Process::PID pid)
+    size_t getMemoryUsagePSS(const pid_t pid)
     {
         if (pid > 0)
         {
@@ -465,7 +464,7 @@ namespace Util
         return 0;
     }
 
-    size_t getMemoryUsageRSS(const Poco::Process::PID pid)
+    size_t getMemoryUsageRSS(const pid_t pid)
     {
         static const int pageSizeBytes = getpagesize();
         size_t rss = 0;
@@ -480,7 +479,7 @@ namespace Util
         return 0;
     }
 
-    size_t getCpuUsage(const Poco::Process::PID pid)
+    size_t getCpuUsage(const pid_t pid)
     {
         if (pid > 0)
         {
@@ -492,7 +491,7 @@ namespace Util
         return 0;
     }
 
-    size_t getStatFromPid(const Poco::Process::PID pid, int ind)
+    size_t getStatFromPid(const pid_t pid, int ind)
     {
         if (pid > 0)
         {
diff --git a/common/Util.hpp b/common/Util.hpp
index d154942f8..105eef7dd 100644
--- a/common/Util.hpp
+++ b/common/Util.hpp
@@ -21,6 +21,7 @@
 #include <set>
 #include <sstream>
 #include <string>
+#include <map>
 #include <inttypes.h>
 
 #include <memory.h>
@@ -31,7 +32,6 @@
 
 #include <Poco/File.h>
 #include <Poco/Path.h>
-#include <Poco/Process.h>
 #include <Poco/RegularExpression.h>
 
 #define LOK_USE_UNSTABLE_API
@@ -135,10 +135,10 @@ namespace Util
     size_t getTotalSystemMemoryKb();
 
     /// Returns the process PSS in KB (works only when we have perms for /proc/pid/smaps).
-    size_t getMemoryUsagePSS(const Poco::Process::PID pid);
+    size_t getMemoryUsagePSS(const pid_t pid);
 
     /// Returns the process RSS in KB.
-    size_t getMemoryUsageRSS(const Poco::Process::PID pid);
+    size_t getMemoryUsageRSS(const pid_t pid);
 
     /// Returns the RSS and PSS of the current process in KB.
     /// Example: "procmemstats: pid=123 rss=12400 pss=566"
@@ -148,9 +148,9 @@ namespace Util
     /// returns them as a pair in the same order
     std::pair<size_t, size_t> getPssAndDirtyFromSMaps(FILE* file);
 
-    size_t getCpuUsage(const Poco::Process::PID pid);
+    size_t getCpuUsage(const pid_t pid);
 
-    size_t getStatFromPid(const Poco::Process::PID pid, int ind);
+    size_t getStatFromPid(const pid_t pid, int ind);
 #endif
 
     std::string replace(std::string s, const std::string& a, const std::string& b);
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index aa9f2545c..f576f2785 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -24,7 +24,6 @@
 #include <Poco/URI.h>
 #include <Poco/BinaryReader.h>
 #include <Poco/Base64Decoder.h>
-#include <Poco/Process.h>
 #if !MOBILEAPP
 #include <Poco/Net/HTTPResponse.h>
 #include <Poco/Net/HTTPSClientSession.h>
@@ -616,7 +615,7 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, const S
 #if defined(ENABLE_DEBUG) && !MOBILEAPP
     if (std::getenv("PAUSEFORDEBUGGER"))
     {
-        std::cerr << getDocURL() << " paused waiting for a debugger to attach: " << Poco::Process::id() << std::endl;
+        std::cerr << getDocURL() << " paused waiting for a debugger to attach: " << getpid() << std::endl;
         SigUtil::setDebuggerSignal();
         pause();
     }
diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp
index b15a4bea2..c820305ff 100644
--- a/kit/ForKit.cpp
+++ b/kit/ForKit.cpp
@@ -28,7 +28,6 @@
 #include <chrono>
 
 #include <Poco/Path.h>
-#include <Poco/Process.h>
 
 #include <Common.hpp>
 #include "Kit.hpp"
@@ -45,8 +44,6 @@
 #include <common/SigUtil.hpp>
 #include <security.h>
 
-using Poco::Process;
-
 #ifndef KIT_IN_PROCESS
 static bool NoCapsForKit = false;
 static bool NoSeccomp = false;
@@ -60,7 +57,7 @@ static std::string UnitTestLibrary;
 static std::string LogLevel;
 static std::atomic<unsigned> ForkCounter(0);
 
-static std::map<Process::PID, std::string> childJails;
+static std::map<pid_t, std::string> childJails;
 
 #ifndef KIT_IN_PROCESS
 int ClientPortNumber = DEFAULT_CLIENT_PORT_NUMBER;
@@ -227,7 +224,7 @@ static bool haveCorrectCapabilities()
 static void cleanupChildren()
 {
     std::vector<std::string> jails;
-    Process::PID exitedChildPid;
+    pid_t exitedChildPid;
     int status, segFaultCount = 0;
 
     // Reap quickly without doing slow cleanup so WSD can spawn more rapidly.
@@ -302,7 +299,7 @@ static int createLibreOfficeKit(const std::string& childRoot,
     ++spareKitId;
     LOG_DBG("Forking a loolkit process with jailId: " << jailId << " as spare loolkit #" << spareKitId << ".");
 
-    const Process::PID pid = fork();
+    const pid_t pid = fork();
     if (!pid)
     {
         // Child
@@ -321,7 +318,7 @@ static int createLibreOfficeKit(const std::string& childRoot,
             {
                 std::cerr << "Kit: Sleeping " << delaySecs
                           << " seconds to give you time to attach debugger to process "
-                          << Process::id() << std::endl;
+                          << getpid() << std::endl;
                 std::this_thread::sleep_for(std::chrono::seconds(delaySecs));
             }
         }
@@ -423,7 +420,7 @@ int main(int argc, char** argv)
         {
             std::cerr << "Forkit: Sleeping " << delaySecs
                       << " seconds to give you time to attach debugger to process "
-                      << Process::id() << std::endl;
+                      << getpid() << std::endl;
             std::this_thread::sleep_for(std::chrono::seconds(delaySecs));
         }
     }
@@ -587,7 +584,7 @@ int main(int argc, char** argv)
     // We must have at least one child, more are created dynamically.
     // Ask this first child to send version information to master process and trace startup.
     ::setenv("LOOL_TRACE_STARTUP", "1", 1);
-    Process::PID forKitPid = createLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath, true);
+    pid_t forKitPid = createLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath, true);
     if (forKitPid < 0)
     {
         LOG_FTL("Failed to create a kit process.");
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 52cd43f8c..db95047f9 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -48,7 +48,6 @@
 #include <Poco/Net/HTTPResponse.h>
 #include <Poco/Net/NetException.h>
 #include <Poco/Net/Socket.h>
-#include <Poco/Process.h>
 #include <Poco/Runnable.h>
 #include <Poco/URI.h>
 
diff --git a/net/Ssl.cpp b/net/Ssl.cpp
index 428239280..5dc8ba874 100644
--- a/net/Ssl.cpp
+++ b/net/Ssl.cpp
@@ -10,10 +10,10 @@
 #include <config.h>
 
 #include <assert.h>
+#include <unistd.h>
 #include "Ssl.hpp"
 
 #include <sys/syscall.h>
-
 #include <Util.hpp>
 
 extern "C"
diff --git a/tools/Config.cpp b/tools/Config.cpp
index 754062a4e..86339915a 100644
--- a/tools/Config.cpp
+++ b/tools/Config.cpp
@@ -14,6 +14,7 @@
 #include <sstream>
 #include <sysexits.h>
 #include <termios.h>
+#include <unistd.h>
 
 #include <openssl/rand.h>
 #include <openssl/evp.h>
diff --git a/tools/KitClient.cpp b/tools/KitClient.cpp
index f7226aa47..54d270677 100644
--- a/tools/KitClient.cpp
+++ b/tools/KitClient.cpp
@@ -21,7 +21,6 @@
 #include <LibreOfficeKit/LibreOfficeKitInit.h>
 
 #include <Poco/Buffer.h>
-#include <Poco/Process.h>
 #include <Poco/String.h>
 #include <Poco/TemporaryFile.h>
 #include <Poco/URI.h>
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index ace0d6e5d..92fe30e8a 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -478,11 +478,11 @@ void Admin::pollingThread()
     }
 }
 
-void Admin::modificationAlert(const std::string& dockey, Poco::Process::PID pid, bool value){
+void Admin::modificationAlert(const std::string& dockey, pid_t pid, bool value){
     addCallback([=] { _model.modificationAlert(dockey, pid, value); });
 }
 
-void Admin::addDoc(const std::string& docKey, Poco::Process::PID pid, const std::string& filename,
+void Admin::addDoc(const std::string& docKey, pid_t pid, const std::string& filename,
                    const std::string& sessionId, const std::string& userName, const std::string& userId,
                    const int smapsFD)
 {
diff --git a/wsd/Admin.hpp b/wsd/Admin.hpp
index 3d9af9ef3..1e7ebe9a6 100644
--- a/wsd/Admin.hpp
+++ b/wsd/Admin.hpp
@@ -79,12 +79,12 @@ public:
     size_t getTotalAvailableMemory() { return _totalAvailMemKb; }
     size_t getTotalCpuUsage();
 
-    void modificationAlert(const std::string& dockey, Poco::Process::PID pid, bool value);
+    void modificationAlert(const std::string& dockey, pid_t pid, bool value);
     /// Update the Admin Model.
     void update(const std::string& message);
 
     /// Calls with same pid will increment view count, if pid already exists
-    void addDoc(const std::string& docKey, Poco::Process::PID pid, const std::string& filename,
+    void addDoc(const std::string& docKey, pid_t pid, const std::string& filename,
                 const std::string& sessionId, const std::string& userName, const std::string& userId,
                 const int smapsFD);
 
diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp
index bebd00b7d..ff99578ae 100644
--- a/wsd/AdminModel.cpp
+++ b/wsd/AdminModel.cpp
@@ -17,7 +17,6 @@
 #include <sstream>
 #include <string>
 
-#include <Poco/Process.h>
 #include <Poco/URI.h>
 
 #include <Protocol.hpp>
@@ -477,7 +476,7 @@ void AdminModel::addBytes(const std::string& docKey, uint64_t sent, uint64_t rec
     _recvBytesTotal += recv;
 }
 
-void AdminModel::modificationAlert(const std::string& docKey, Poco::Process::PID pid, bool value)
+void AdminModel::modificationAlert(const std::string& docKey, pid_t pid, bool value)
 {
     assertCorrectThread();
 
@@ -493,7 +492,7 @@ void AdminModel::modificationAlert(const std::string& docKey, Poco::Process::PID
     notify(oss.str());
 }
 
-void AdminModel::addDocument(const std::string& docKey, Poco::Process::PID pid,
+void AdminModel::addDocument(const std::string& docKey, pid_t pid,
                              const std::string& filename, const std::string& sessionId,
                              const std::string& userName, const std::string& userId,
                              const int smapsFD)
diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp
index 862b02b1b..63f61d5c9 100644
--- a/wsd/AdminModel.hpp
+++ b/wsd/AdminModel.hpp
@@ -15,8 +15,6 @@
 #include <cmath>
 #include <list>
 
-#include <Poco/Process.h>
-
 #include "Log.hpp"
 #include "net/WebSocketHandler.hpp"
 #include "Util.hpp"
@@ -106,7 +104,7 @@ class Document
 
 public:
     Document(const std::string& docKey,
-             Poco::Process::PID pid,
+             pid_t pid,
              const std::string& filename)
         : _docKey(docKey),
           _pid(pid),
@@ -135,7 +133,7 @@ public:
 
     const std::string getDocKey() const { return _docKey; }
 
-    Poco::Process::PID getPid() const { return _pid; }
+    pid_t getPid() const { return _pid; }
 
     std::string getFilename() const { return _filename; }
 
@@ -189,7 +187,7 @@ public:
 
 private:
     const std::string _docKey;
-    const Poco::Process::PID _pid;
+    const pid_t _pid;
     /// SessionId mapping to View object
     std::map<std::string, View> _views;
     /// Total number of active views
@@ -291,7 +289,7 @@ public:
 
     void unsubscribe(int sessionId, const std::string& command);
 
-    void modificationAlert(const std::string& docKey, Poco::Process::PID pid, bool value);
+    void modificationAlert(const std::string& docKey, pid_t pid, bool value);
 
     void clearMemStats() { _memStats.clear(); }
 
@@ -311,7 +309,7 @@ public:
 
     void notify(const std::string& message);
 
-    void addDocument(const std::string& docKey, Poco::Process::PID pid, const std::string& filename,
+    void addDocument(const std::string& docKey, pid_t pid, const std::string& filename,
                      const std::string& sessionId, const std::string& userName, const std::string& userId,
                      const int smapsFD);
 
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index a5bc5c160..61f74f5a7 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -67,7 +67,7 @@ class ChildProcess : public WSProcess
 public:
     /// @param pid is the process ID of the child.
     /// @param socket is the underlying Sockeet to the child.
-    ChildProcess(const Poco::Process::PID pid,
+    ChildProcess(const pid_t pid,
                  const std::string& jailId,
                  const std::shared_ptr<StreamSocket>& socket,
                  const Poco::Net::HTTPRequest &request) :
@@ -259,7 +259,7 @@ public:
     void closeDocument(const std::string& reason);
 
     /// Get the PID of the associated child process
-    Poco::Process::PID getPid() const { return _childProcess ? _childProcess->getPid() : 0; }
+    pid_t getPid() const { return _childProcess ? _childProcess->getPid() : 0; }
 
     std::unique_lock<std::mutex> getLock() { return std::unique_lock<std::mutex>(_mutex); }
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index ba66a372d..dbabc5b9b 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -91,7 +91,6 @@ using Poco::Net::PartHandler;
 #include <Poco/Net/DNS.h>
 #include <Poco/Net/HostEntry.h>
 #include <Poco/Path.h>
-#include <Poco/Process.h>
 #include <Poco/SAX/InputSource.h>
 #include <Poco/StreamCopier.h>
 #include <Poco/StringTokenizer.h>
@@ -2024,7 +2023,7 @@ private:
 
             UnitWSD::get().newChild(*this);
 #else
-            Poco::Process::PID pid = 100;
+            pid_t pid = 100;
             std::string jailId = "jail";
             socket->getInBuffer().clear();
 #endif
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 07561906e..f2f7e0abc 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -19,7 +19,6 @@
 #include <signal.h>
 
 #include <Poco/Path.h>
-#include <Poco/Process.h>
 #include <Poco/Util/AbstractConfiguration.h>
 #include <Poco/Util/OptionSet.h>
 #include <Poco/Util/ServerApplication.h>
@@ -48,7 +47,7 @@ public:
     /// @param pid is the process ID.
     /// @param socket is the underlying Sockeet to the process.
     WSProcess(const std::string& name,
-              const Poco::Process::PID pid,
+              const pid_t pid,
               const std::shared_ptr<StreamSocket>& socket,
               std::shared_ptr<WebSocketHandler> handler) :
 
@@ -130,7 +129,7 @@ public:
         _pid = -1;
     }
 
-    Poco::Process::PID getPid() const { return _pid; }
+    pid_t getPid() const { return _pid; }
 
     /// Send a text payload to the child-process WS.
     virtual bool sendTextFrame(const std::string& data)
@@ -176,7 +175,7 @@ public:
     }
 
     std::string _name;
-    Poco::Process::PID _pid;
+    pid_t _pid;
     std::shared_ptr<WebSocketHandler> _ws;
     std::shared_ptr<Socket> _socket;
 };


More information about the Libreoffice-commits mailing list