2016-03-10 20:42:33 -06:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2016-03-12 18:29:17 -06:00
|
|
|
#ifndef INCLUDED_DOCUMENTBROKER_HPP
|
|
|
|
#define INCLUDED_DOCUMENTBROKER_HPP
|
2016-03-10 20:42:33 -06:00
|
|
|
|
2016-08-30 02:06:39 -05:00
|
|
|
#include <csignal>
|
2016-04-03 20:40:14 -05:00
|
|
|
|
2016-03-10 20:42:33 -06:00
|
|
|
#include <atomic>
|
2016-04-10 21:07:09 -05:00
|
|
|
#include <chrono>
|
2016-05-16 22:02:05 -05:00
|
|
|
#include <condition_variable>
|
loolwsd: include cleanup and organization
A source file (.cpp) must include its own header first.
This insures that the header is self-contained and
doesn't depend on arbitrary (and accidental) includes
before it to compile.
Furthermore, system headers should go next, followed by
C then C++ headers, then libraries (Poco, etc) and, finally,
project headers come last.
This makes sure that headers and included in the same dependency
order to avoid side-effects. For example, Poco should never rely on
anything from our project in the same way that a C header should
never rely on anything in C++, Poco, or project headers.
Also, includes ought to be sorted where possible, to improve
readability and avoid accidental duplicates (of which there
were a few).
Change-Id: I62cc1343e4a091d69195e37ed659dba20cfcb1ef
Reviewed-on: https://gerrit.libreoffice.org/25262
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 09:23:07 -05:00
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
2016-03-10 20:42:33 -06:00
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
2016-05-02 06:21:30 -05:00
|
|
|
#include <thread>
|
2016-03-10 20:42:33 -06:00
|
|
|
|
2016-10-29 20:15:00 -05:00
|
|
|
#include <Poco/URI.h>
|
2016-03-25 21:56:18 -05:00
|
|
|
|
2016-04-05 21:37:29 -05:00
|
|
|
#include "IoUtil.hpp"
|
loolwsd: include cleanup and organization
A source file (.cpp) must include its own header first.
This insures that the header is self-contained and
doesn't depend on arbitrary (and accidental) includes
before it to compile.
Furthermore, system headers should go next, followed by
C then C++ headers, then libraries (Poco, etc) and, finally,
project headers come last.
This makes sure that headers and included in the same dependency
order to avoid side-effects. For example, Poco should never rely on
anything from our project in the same way that a C header should
never rely on anything in C++, Poco, or project headers.
Also, includes ought to be sorted where possible, to improve
readability and avoid accidental duplicates (of which there
were a few).
Change-Id: I62cc1343e4a091d69195e37ed659dba20cfcb1ef
Reviewed-on: https://gerrit.libreoffice.org/25262
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 09:23:07 -05:00
|
|
|
#include "Log.hpp"
|
2016-11-10 02:47:25 -06:00
|
|
|
#include <LOOLWebSocket.hpp>
|
2016-07-19 12:10:14 -05:00
|
|
|
#include "Storage.hpp"
|
2016-05-16 22:02:05 -05:00
|
|
|
#include "TileCache.hpp"
|
2016-03-23 11:55:28 -05:00
|
|
|
#include "Util.hpp"
|
2016-03-25 21:56:18 -05:00
|
|
|
|
2016-11-14 07:58:04 -06:00
|
|
|
#include "common/SigUtil.hpp"
|
|
|
|
|
2016-03-25 21:56:18 -05:00
|
|
|
// Forwards.
|
2016-05-16 19:49:36 -05:00
|
|
|
class DocumentBroker;
|
2016-03-10 20:42:33 -06:00
|
|
|
|
2016-04-03 20:40:14 -05:00
|
|
|
/// Represents a new LOK child that is read
|
|
|
|
/// to host a document.
|
|
|
|
class ChildProcess
|
|
|
|
{
|
|
|
|
public:
|
2016-04-29 05:06:45 -05:00
|
|
|
/// @param pid is the process ID of the child.
|
2016-11-10 02:47:25 -06:00
|
|
|
/// @param ws is the control LOOLWebSocket to the child.
|
|
|
|
ChildProcess(const Poco::Process::PID pid, const std::shared_ptr<LOOLWebSocket>& ws) :
|
2016-04-03 20:40:14 -05:00
|
|
|
_pid(pid),
|
2016-05-02 06:21:30 -05:00
|
|
|
_ws(ws),
|
|
|
|
_stop(false)
|
2016-04-03 20:40:14 -05:00
|
|
|
{
|
2016-05-02 06:21:30 -05:00
|
|
|
_thread = std::thread([this]() { this->socketProcessor(); });
|
2016-11-06 10:59:59 -06:00
|
|
|
LOG_INF("ChildProcess ctor [" << _pid << "].");
|
2016-04-03 20:40:14 -05:00
|
|
|
}
|
|
|
|
|
2016-05-01 19:30:52 -05:00
|
|
|
ChildProcess(ChildProcess&& other) = delete;
|
2016-04-03 20:40:14 -05:00
|
|
|
|
2016-05-01 19:30:52 -05:00
|
|
|
const ChildProcess& operator=(ChildProcess&& other) = delete;
|
2016-04-03 20:40:14 -05:00
|
|
|
|
|
|
|
~ChildProcess()
|
|
|
|
{
|
2016-11-06 10:59:59 -06:00
|
|
|
LOG_DBG("~ChildProcess dtor [" << _pid << "].");
|
2016-10-22 18:10:07 -05:00
|
|
|
close(true);
|
2016-04-03 20:40:14 -05:00
|
|
|
}
|
|
|
|
|
2016-05-02 06:21:30 -05:00
|
|
|
void setDocumentBroker(const std::shared_ptr<DocumentBroker>& docBroker)
|
|
|
|
{
|
2016-10-09 10:28:22 -05:00
|
|
|
assert(docBroker && "Invalid DocumentBroker instance.");
|
2016-05-02 06:21:30 -05:00
|
|
|
_docBroker = docBroker;
|
|
|
|
}
|
|
|
|
|
2016-10-22 18:10:07 -05:00
|
|
|
void stop()
|
|
|
|
{
|
2016-11-06 10:59:59 -06:00
|
|
|
LOG_DBG("Stopping ChildProcess [" << _pid << "]");
|
2016-10-22 18:10:07 -05:00
|
|
|
_stop = true;
|
2016-11-06 20:16:11 -06:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (_pid != -1 && _ws)
|
|
|
|
{
|
|
|
|
sendTextFrame("exit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const std::exception&)
|
|
|
|
{
|
2016-11-22 23:21:12 -06:00
|
|
|
// Already logged in sendTextFrame.
|
2016-11-06 20:16:11 -06:00
|
|
|
}
|
2016-10-22 18:10:07 -05:00
|
|
|
}
|
|
|
|
|
2016-04-03 20:40:14 -05:00
|
|
|
void close(const bool rude)
|
|
|
|
{
|
2016-10-14 07:37:43 -05:00
|
|
|
try
|
2016-04-03 20:40:14 -05:00
|
|
|
{
|
2016-11-06 10:59:59 -06:00
|
|
|
LOG_DBG("Closing ChildProcess [" << _pid << "].");
|
2016-10-22 18:10:07 -05:00
|
|
|
stop();
|
2016-10-14 07:37:43 -05:00
|
|
|
IoUtil::shutdownWebSocket(_ws);
|
|
|
|
if (_thread.joinable())
|
2016-04-03 20:40:14 -05:00
|
|
|
{
|
2016-10-14 07:37:43 -05:00
|
|
|
_thread.join();
|
2016-04-03 20:40:14 -05:00
|
|
|
}
|
|
|
|
|
2016-10-14 07:37:43 -05:00
|
|
|
_ws.reset();
|
2016-11-13 15:12:01 -06:00
|
|
|
if (_pid != -1 && rude && kill(_pid, 0) != 0 && errno != ESRCH)
|
2016-10-14 07:37:43 -05:00
|
|
|
{
|
2016-11-13 15:12:01 -06:00
|
|
|
LOG_INF("Killing child [" << _pid << "].");
|
2016-11-14 07:58:04 -06:00
|
|
|
if (SigUtil::killChild(_pid))
|
2016-10-14 07:37:43 -05:00
|
|
|
{
|
2016-11-13 15:12:01 -06:00
|
|
|
LOG_ERR("Cannot terminate lokit [" << _pid << "]. Abandoning.");
|
2016-10-14 07:37:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const std::exception& ex)
|
|
|
|
{
|
2016-11-06 10:59:59 -06:00
|
|
|
LOG_ERR("Error while closing child process: " << ex.what());
|
2016-04-03 20:40:14 -05:00
|
|
|
}
|
2016-11-13 15:12:01 -06:00
|
|
|
|
|
|
|
_pid = -1;
|
2016-04-03 20:40:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Poco::Process::PID getPid() const { return _pid; }
|
2016-10-11 17:22:51 -05:00
|
|
|
|
|
|
|
/// Send a text payload to the child-process WS.
|
|
|
|
bool sendTextFrame(const std::string& data)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2016-11-06 20:16:11 -06:00
|
|
|
if (_ws)
|
|
|
|
{
|
|
|
|
LOG_TRC("DocBroker to Child: " << data);
|
|
|
|
_ws->sendFrame(data.data(), data.size());
|
|
|
|
return true;
|
|
|
|
}
|
2016-10-11 17:22:51 -05:00
|
|
|
}
|
|
|
|
catch (const std::exception& exc)
|
|
|
|
{
|
2016-11-06 10:59:59 -06:00
|
|
|
LOG_ERR("Failed to send child [" << _pid << "] data [" <<
|
|
|
|
data << "] due to: " << exc.what());
|
2016-10-11 17:22:51 -05:00
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
2016-11-06 20:16:11 -06:00
|
|
|
LOG_WRN("No socket between DocBroker and child to send [" << data << "]");
|
2016-10-11 17:22:51 -05:00
|
|
|
return false;
|
|
|
|
}
|
2016-04-03 20:40:14 -05:00
|
|
|
|
2016-04-24 10:56:02 -05:00
|
|
|
/// Check whether this child is alive and able to respond.
|
2016-11-13 15:12:01 -06:00
|
|
|
/// Note: zombies will show as alive, and sockets have waiting
|
|
|
|
/// time after the other end-point closes. So this isn't accurate.
|
2016-04-24 10:56:02 -05:00
|
|
|
bool isAlive() const
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2016-11-08 23:47:42 -06:00
|
|
|
using namespace Poco::Net;
|
|
|
|
return (_pid > 1 && _ws && kill(_pid, 0) == 0 &&
|
|
|
|
_ws->poll(Poco::Timespan(0), Socket::SelectMode::SELECT_WRITE) &&
|
|
|
|
!_ws->poll(Poco::Timespan(0), Socket::SelectMode::SELECT_ERROR));
|
2016-04-24 10:56:02 -05:00
|
|
|
}
|
|
|
|
catch (const std::exception& exc)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-02 06:21:30 -05:00
|
|
|
private:
|
|
|
|
void socketProcessor();
|
|
|
|
|
2016-04-03 20:40:14 -05:00
|
|
|
private:
|
|
|
|
Poco::Process::PID _pid;
|
2016-11-10 02:47:25 -06:00
|
|
|
std::shared_ptr<LOOLWebSocket> _ws;
|
2016-05-02 06:21:30 -05:00
|
|
|
std::weak_ptr<DocumentBroker> _docBroker;
|
|
|
|
std::thread _thread;
|
|
|
|
std::atomic<bool> _stop;
|
2016-04-03 20:40:14 -05:00
|
|
|
};
|
|
|
|
|
2016-05-16 06:37:02 -05:00
|
|
|
class PrisonerSession;
|
2016-05-16 06:46:27 -05:00
|
|
|
class ClientSession;
|
2016-05-16 06:37:02 -05:00
|
|
|
|
2016-03-12 18:29:17 -06:00
|
|
|
/// DocumentBroker is responsible for setting up a document
|
|
|
|
/// in jail and brokering loading it from Storage
|
|
|
|
/// and saving it back.
|
2016-03-10 20:42:33 -06:00
|
|
|
/// Contains URI, physical path, etc.
|
2016-10-12 22:04:07 -05:00
|
|
|
class DocumentBroker : public std::enable_shared_from_this<DocumentBroker>
|
2016-03-10 20:42:33 -06:00
|
|
|
{
|
|
|
|
public:
|
2016-04-13 03:05:00 -05:00
|
|
|
static Poco::URI sanitizeURI(const std::string& uri);
|
2016-03-19 17:49:36 -05:00
|
|
|
|
|
|
|
/// Returns a document-specific key based
|
|
|
|
/// on the URI of the document.
|
2016-10-29 20:15:00 -05:00
|
|
|
static std::string getDocKey(const Poco::URI& uri);
|
2016-09-15 05:41:57 -05:00
|
|
|
|
|
|
|
/// Dummy document broker that is marked to destroy.
|
|
|
|
DocumentBroker();
|
2016-03-12 18:29:17 -06:00
|
|
|
|
2016-03-19 17:49:36 -05:00
|
|
|
DocumentBroker(const Poco::URI& uriPublic,
|
|
|
|
const std::string& docKey,
|
2016-04-03 20:40:14 -05:00
|
|
|
const std::string& childRoot,
|
2016-10-14 21:52:33 -05:00
|
|
|
const std::shared_ptr<ChildProcess>& childProcess);
|
2016-03-12 18:29:17 -06:00
|
|
|
|
2016-10-22 09:25:57 -05:00
|
|
|
~DocumentBroker();
|
2016-03-12 18:29:17 -06:00
|
|
|
|
|
|
|
/// Loads a document from the public URI into the jail.
|
2016-11-06 22:14:23 -06:00
|
|
|
bool load(std::shared_ptr<ClientSession>& session, const std::string& jailId);
|
2016-04-29 22:07:09 -05:00
|
|
|
bool isLoaded() const { return _isLoaded; }
|
|
|
|
void setLoaded() { _isLoaded = true; }
|
2016-03-12 18:29:17 -06:00
|
|
|
|
2016-04-25 19:48:02 -05:00
|
|
|
/// Save the document to Storage if needs persisting.
|
2016-10-16 11:40:52 -05:00
|
|
|
bool save(const std::string& sesionId, bool success, const std::string& result = "");
|
2016-04-24 10:08:08 -05:00
|
|
|
bool isModified() const { return _isModified; }
|
|
|
|
void setModified(const bool value);
|
2016-03-10 21:01:34 -06:00
|
|
|
|
2016-04-25 19:48:02 -05:00
|
|
|
/// Save the document if the document is modified.
|
2016-04-29 05:06:45 -05:00
|
|
|
/// @param force when true, will force saving if there
|
2016-04-25 19:48:02 -05:00
|
|
|
/// has been any recent activity after the last save.
|
2016-04-29 05:06:45 -05:00
|
|
|
/// @param waitTimeoutMs when >0 will wait for the save to
|
2016-04-25 19:48:02 -05:00
|
|
|
/// complete before returning, or timeout.
|
2016-04-29 05:06:45 -05:00
|
|
|
/// @return true if attempts to save or it also waits
|
2016-04-25 19:48:02 -05:00
|
|
|
/// and receives save notification. Otherwise, false.
|
2016-11-05 21:15:44 -05:00
|
|
|
bool autoSave(const bool force, const size_t waitTimeoutMs, std::unique_lock<std::mutex>& lock);
|
2016-04-09 22:20:20 -05:00
|
|
|
|
2016-03-10 20:42:33 -06:00
|
|
|
Poco::URI getPublicUri() const { return _uriPublic; }
|
|
|
|
Poco::URI getJailedUri() const { return _uriJailed; }
|
2016-03-12 18:29:17 -06:00
|
|
|
const std::string& getJailId() const { return _jailId; }
|
|
|
|
const std::string& getDocKey() const { return _docKey; }
|
2016-04-14 15:29:31 -05:00
|
|
|
const std::string& getFilename() const { return _filename; };
|
2016-03-25 21:56:18 -05:00
|
|
|
TileCache& tileCache() { return *_tileCache; }
|
2016-04-24 10:56:02 -05:00
|
|
|
bool isAlive() const { return _childProcess && _childProcess->isAlive(); }
|
2016-04-16 16:18:51 -05:00
|
|
|
size_t getSessionsCount() const
|
2016-04-10 12:03:57 -05:00
|
|
|
{
|
2016-11-05 21:15:44 -05:00
|
|
|
Util::assertIsLocked(_mutex);
|
2016-04-16 16:18:51 -05:00
|
|
|
return _sessions.size();
|
2016-04-10 12:03:57 -05:00
|
|
|
}
|
2016-03-10 20:42:33 -06:00
|
|
|
|
2016-04-29 05:06:45 -05:00
|
|
|
/// @eturn the time in milliseconds since last save.
|
2016-04-09 22:20:20 -05:00
|
|
|
double getTimeSinceLastSaveMs() const
|
|
|
|
{
|
|
|
|
const auto duration = (std::chrono::steady_clock::now() - _lastSaveTime);
|
|
|
|
return std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
|
|
|
|
}
|
|
|
|
|
2016-03-23 07:41:18 -05:00
|
|
|
std::string getJailRoot() const;
|
2016-03-12 19:14:32 -06:00
|
|
|
|
2016-04-16 16:18:51 -05:00
|
|
|
/// Add a new session. Returns the new number of sessions.
|
2016-05-16 06:46:27 -05:00
|
|
|
size_t addSession(std::shared_ptr<ClientSession>& session);
|
2016-04-16 16:18:51 -05:00
|
|
|
/// Removes a session by ID. Returns the new number of sessions.
|
|
|
|
size_t removeSession(const std::string& id);
|
2016-03-23 11:55:28 -05:00
|
|
|
|
2016-11-17 08:00:05 -06:00
|
|
|
void alertAllUsers(const std::string& msg);
|
|
|
|
|
|
|
|
void alertAllUsers(const std::string& cmd, const std::string& kind)
|
|
|
|
{
|
|
|
|
alertAllUsers("error: cmd=" + cmd + " kind=" + kind);
|
|
|
|
}
|
2016-09-28 14:07:07 -05:00
|
|
|
|
2016-05-22 15:47:22 -05:00
|
|
|
/// Invalidate the cursor position.
|
2016-09-01 15:15:13 -05:00
|
|
|
void invalidateCursor(int x, int y, int w, int h)
|
2016-05-22 15:47:22 -05:00
|
|
|
{
|
|
|
|
_cursorPosX = x;
|
|
|
|
_cursorPosY = y;
|
2016-09-01 15:15:13 -05:00
|
|
|
_cursorWidth = w;
|
|
|
|
_cursorHeight = h;
|
2016-05-22 15:47:22 -05:00
|
|
|
}
|
|
|
|
|
2016-09-20 21:19:52 -05:00
|
|
|
void invalidateTiles(const std::string& tiles);
|
2016-05-22 13:31:18 -05:00
|
|
|
void handleTileRequest(TileDesc& tile,
|
2016-05-16 19:49:36 -05:00
|
|
|
const std::shared_ptr<ClientSession>& session);
|
2016-05-22 10:45:28 -05:00
|
|
|
void handleTileCombinedRequest(TileCombined& tileCombined,
|
|
|
|
const std::shared_ptr<ClientSession>& session);
|
2016-08-30 22:15:44 -05:00
|
|
|
void cancelTileRequests(const std::shared_ptr<ClientSession>& session);
|
2016-05-01 19:50:11 -05:00
|
|
|
void handleTileResponse(const std::vector<char>& payload);
|
2016-05-22 10:45:28 -05:00
|
|
|
void handleTileCombinedResponse(const std::vector<char>& payload);
|
2016-05-01 19:50:11 -05:00
|
|
|
|
2016-10-08 09:31:35 -05:00
|
|
|
/// Called before destroying any session.
|
|
|
|
/// This method calculates and sets important states of
|
|
|
|
/// session being destroyed. Returns true if session id
|
|
|
|
/// is the last editable session.
|
|
|
|
bool startDestroy(const std::string& id);
|
2016-04-17 22:29:03 -05:00
|
|
|
bool isMarkedToDestroy() const { return _markToDestroy; }
|
2016-04-15 04:00:22 -05:00
|
|
|
|
2016-05-02 06:21:30 -05:00
|
|
|
bool handleInput(const std::vector<char>& payload);
|
|
|
|
|
2016-10-08 13:25:27 -05:00
|
|
|
/// Forward a message from client session to its respective child session.
|
2016-10-16 12:43:44 -05:00
|
|
|
bool forwardToChild(const std::string& viewId, const std::string& message);
|
2016-10-08 13:25:27 -05:00
|
|
|
|
2016-10-11 07:39:56 -05:00
|
|
|
int getRenderedTileCount() { return _debugRenderedTileCount; }
|
|
|
|
|
2016-11-08 07:37:28 -06:00
|
|
|
void closeDocument(const std::string& reason);
|
|
|
|
|
2016-10-29 20:15:00 -05:00
|
|
|
/// Called by the ChildProcess object to notify
|
|
|
|
/// that it has terminated on its own.
|
|
|
|
/// This happens either when the child exists
|
|
|
|
/// or upon failing to process an incoming message.
|
2016-10-15 16:07:40 -05:00
|
|
|
void childSocketTerminated();
|
|
|
|
|
2016-11-05 22:00:16 -05:00
|
|
|
/// This gracefully terminates the connection
|
|
|
|
/// with the child and cleans up ChildProcess etc.
|
|
|
|
/// We must be called under lock and it must be
|
|
|
|
/// passed to us so we unlock before waiting on
|
|
|
|
/// the ChildProcess thread, which can take our lock.
|
2016-11-08 07:37:28 -06:00
|
|
|
void terminateChild(std::unique_lock<std::mutex>& lock, const std::string& closeReason = "");
|
2016-11-05 22:00:16 -05:00
|
|
|
|
2016-10-17 06:45:58 -05:00
|
|
|
/// Get the PID of the associated child process
|
|
|
|
Poco::Process::PID getPid() const { return _childProcess->getPid(); }
|
|
|
|
|
2016-11-05 21:15:44 -05:00
|
|
|
std::unique_lock<std::mutex> getLock() { return std::unique_lock<std::mutex>(_mutex); }
|
|
|
|
|
2016-12-05 14:11:07 -06:00
|
|
|
void updateLastActivityTime();
|
|
|
|
|
2016-04-25 19:48:02 -05:00
|
|
|
private:
|
|
|
|
/// Sends the .uno:Save command to LoKit.
|
2016-07-14 04:49:21 -05:00
|
|
|
bool sendUnoSave(const bool dontSaveIfUnmodified);
|
2016-04-25 19:48:02 -05:00
|
|
|
|
|
|
|
/// Saves the document to Storage (assuming LO Core saved to local copy).
|
|
|
|
bool saveToStorage();
|
|
|
|
|
2016-10-08 17:21:35 -05:00
|
|
|
/// Forward a message from child session to its respective client session.
|
2016-10-08 12:13:23 -05:00
|
|
|
bool forwardToClient(const std::string& prefix, const std::vector<char>& payload);
|
|
|
|
|
2016-03-10 20:42:33 -06:00
|
|
|
private:
|
|
|
|
const Poco::URI _uriPublic;
|
2016-03-12 18:29:17 -06:00
|
|
|
const std::string _docKey;
|
2016-03-12 19:14:32 -06:00
|
|
|
const std::string _childRoot;
|
2016-03-26 06:50:13 -05:00
|
|
|
const std::string _cacheRoot;
|
2016-04-24 10:08:08 -05:00
|
|
|
std::shared_ptr<ChildProcess> _childProcess;
|
2016-03-12 18:29:17 -06:00
|
|
|
Poco::URI _uriJailed;
|
|
|
|
std::string _jailId;
|
2016-03-21 18:12:00 -05:00
|
|
|
std::string _filename;
|
2016-04-09 22:20:20 -05:00
|
|
|
std::chrono::steady_clock::time_point _lastSaveTime;
|
2016-04-25 19:44:24 -05:00
|
|
|
Poco::Timestamp _lastFileModifiedTime;
|
2016-10-29 20:15:00 -05:00
|
|
|
std::map<std::string, std::shared_ptr<ClientSession> > _sessions;
|
2016-03-10 21:01:34 -06:00
|
|
|
std::unique_ptr<StorageBase> _storage;
|
2016-03-25 21:56:18 -05:00
|
|
|
std::unique_ptr<TileCache> _tileCache;
|
2016-04-25 04:21:54 -05:00
|
|
|
std::atomic<bool> _markToDestroy;
|
2016-07-10 23:50:25 -05:00
|
|
|
std::atomic<bool> _lastEditableSession;
|
2016-10-08 09:31:35 -05:00
|
|
|
std::atomic<bool> _isLoaded;
|
|
|
|
std::atomic<bool> _isModified;
|
2016-05-22 15:47:22 -05:00
|
|
|
int _cursorPosX;
|
|
|
|
int _cursorPosY;
|
2016-09-01 15:15:13 -05:00
|
|
|
int _cursorWidth;
|
|
|
|
int _cursorHeight;
|
2016-04-16 16:18:51 -05:00
|
|
|
mutable std::mutex _mutex;
|
2016-04-10 21:07:09 -05:00
|
|
|
std::condition_variable _saveCV;
|
|
|
|
std::mutex _saveMutex;
|
2016-04-09 22:20:20 -05:00
|
|
|
|
2016-05-22 13:31:18 -05:00
|
|
|
/// Versioning is used to prevent races between
|
|
|
|
/// painting and invalidation.
|
|
|
|
std::atomic<size_t> _tileVersion;
|
|
|
|
|
2016-10-11 07:39:56 -05:00
|
|
|
int _debugRenderedTileCount;
|
|
|
|
|
2016-04-09 22:20:20 -05:00
|
|
|
static constexpr auto IdleSaveDurationMs = 30 * 1000;
|
|
|
|
static constexpr auto AutoSaveDurationMs = 300 * 1000;
|
2016-03-10 20:42:33 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|