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

Henry Castro hcastro at collabora.com
Fri Jul 24 12:20:37 PDT 2015


 loolwsd/LOOLSession.cpp |   38 +-------------------------------------
 loolwsd/LOOLSession.hpp |    6 ------
 loolwsd/LOOLWSD.cpp     |    3 +--
 loolwsd/LOOLWSD.hpp     |    2 +-
 4 files changed, 3 insertions(+), 46 deletions(-)

New commits:
commit ec094f1601d68ae54cedf53e3ab2ab8a6d0735a5
Author: Henry Castro <hcastro at collabora.com>
Date:   Fri Jul 24 15:17:46 2015 -0400

    loolwsd: remove _pendingPreSpawnedChildren.
    
    _pendingPreSpawnedChildren is no longer need it, because
    fork() is used.
    Also adjusted time sleep to 1 second.

diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 3b33f13..737435a 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -124,7 +124,6 @@ void LOOLSession::sendBinaryFrame(const char *buffer, int length)
 
 std::map<Process::PID, UInt64> MasterProcessSession::_childProcesses;
 
-std::set<UInt64> MasterProcessSession::_pendingPreSpawnedChildren;
 std::set<std::shared_ptr<MasterProcessSession>> MasterProcessSession::_availableChildSessions;
 std::mutex MasterProcessSession::_availableChildSessionMutex;
 std::condition_variable MasterProcessSession::_availableChildSessionCV;
@@ -231,20 +230,7 @@ bool MasterProcessSession::handleInput(const char *buffer, int length)
         }
 
         UInt64 childId = std::stoull(tokens[1]);
-        // TODO. rework, the desktop and its childrem is jail root same folder
-        /*if (_pendingPreSpawnedChildren.find(childId) == _pendingPreSpawnedChildren.end())
-        {
-            std::cout << Util::logPrefix() << "Error _pendingPreSpawnedChildren.find(childId)" << this << " id=" << childId << std::endl;
-
-            sendTextFrame("error: cmd=child kind=notfound");
-            return false;
-        }*/
 
-        if (_pendingPreSpawnedChildren.size() > 0)
-        {
-            std::set<UInt64>::iterator it = _pendingPreSpawnedChildren.begin();
-            _pendingPreSpawnedChildren.erase(it);
-        }
         std::unique_lock<std::mutex> lock(_availableChildSessionMutex);
         _availableChildSessions.insert(shared_from_this());
         std::cout << Util::logPrefix() << "Inserted " << this << " id=" << childId << " into _availableChildSessions, size=" << _availableChildSessions.size() << std::endl;
@@ -335,22 +321,6 @@ Path MasterProcessSession::getJailPath(UInt64 childId)
     return Path::forDirectory(LOOLWSD::childRoot + Path::separator() + std::to_string(childId));
 }
 
-void MasterProcessSession::addPendingChildrem(UInt64 childId)
-{
-    _pendingPreSpawnedChildren.insert(childId);
-}
-
-int  MasterProcessSession::getAvailableChildSessions()
-{
-    return _availableChildSessions.size();
-}
-
-int  MasterProcessSession::getPendingPreSpawnedChildren()
-{
-    return _pendingPreSpawnedChildren.size();
-}
-
-
 bool MasterProcessSession::invalidateTiles(const char *buffer, int length, StringTokenizer& tokens)
 {
     int part, tilePosX, tilePosY, tileWidth, tileHeight;
@@ -483,16 +453,10 @@ void MasterProcessSession::dispatchChild()
     std::shared_ptr<MasterProcessSession> childSession;
     std::unique_lock<std::mutex> lock(_availableChildSessionMutex);
 
-    std::cout << Util::logPrefix() << "_availableChildSessions size=" << _availableChildSessions.size() << " _pendingChildSessions size=" << _pendingPreSpawnedChildren.size() << std::endl;
+    std::cout << Util::logPrefix() << "_availableChildSessions size=" << _availableChildSessions.size() << std::endl;
 
     if (_availableChildSessions.size() == 0)
     {
-        if (_pendingPreSpawnedChildren.size() == 0)
-        {
-            // Running out of pre-spawned children, so spawn one more
-            Application::instance().logger().information(Util::logPrefix() + "Running out of pre-spawned childred, adding one more");
-        }
-
         std::cout << Util::logPrefix() << "waiting for a child session to become available" << std::endl;
         _availableChildSessionCV.wait(lock, [] { return _availableChildSessions.size() > 0; });
         std::cout << Util::logPrefix() << "waiting done" << std::endl;
diff --git a/loolwsd/LOOLSession.hpp b/loolwsd/LOOLSession.hpp
index 361f6fb..d6b7b60 100644
--- a/loolwsd/LOOLSession.hpp
+++ b/loolwsd/LOOLSession.hpp
@@ -104,9 +104,6 @@ public:
     bool haveSeparateProcess();
 
     static Poco::Path getJailPath(Poco::UInt64 childId);
-    static void addPendingChildrem(Poco::UInt64 childId);
-    static int  getAvailableChildSessions();
-    static int  getPendingPreSpawnedChildren();
 
     static std::map<Poco::Process::PID, Poco::UInt64> _childProcesses;
 
@@ -131,9 +128,6 @@ public:
     // per document being edited (i.e., per child process).
     std::weak_ptr<MasterProcessSession> _peer;
 
-    // Pre-spawned child processes that haven't yet connected.
-    static std::set<Poco::UInt64> _pendingPreSpawnedChildren;
-
     // Sessions to pre-spawned child processes that have connected but are not yet assigned a
     // document to work on.
     static std::set<std::shared_ptr<MasterProcessSession>> _availableChildSessions;
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 7684d82..ae2ed32 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -830,7 +830,6 @@ int LOOLWSD::createComponent()
         componentMain();
     }
 
-    MasterProcessSession::addPendingChildrem(pid);
     MasterProcessSession::_childProcesses[pid] = pid;
 
     return Application::EXIT_OK;
@@ -1110,7 +1109,7 @@ int LOOLWSD::main(const std::vector<std::string>& args)
         if (timeoutCounter == INTERVAL_PROBES)
         {
             timeoutCounter = 0;
-            sleep(MAINTENANCE_INTERVAL);
+            sleep(MAINTENANCE_INTERVAL*2);
         }
     }
 
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index 2824409..331e9f3 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -43,7 +43,7 @@ public:
     static const int DEFAULT_CLIENT_PORT_NUMBER = 9980;
     static const int MASTER_PORT_NUMBER = 9981;
     static const int INTERVAL_PROBES = 10;
-    static const int MAINTENANCE_INTERVAL = 1000000;
+    static const int MAINTENANCE_INTERVAL = 1;
     static const std::string CHILD_URI;
     static const std::string PIDLOG;
 


More information about the Libreoffice-commits mailing list