wsd: initialization and logging

Change-Id: Icd82a966b94875a65ddb3817c88a3c4c7bedd4ff
Reviewed-on: https://gerrit.libreoffice.org/36030
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
Ashod Nakashian 2017-04-02 17:49:14 -04:00 committed by Ashod Nakashian
parent e0822f8516
commit d6577654bd
3 changed files with 13 additions and 11 deletions

View file

@ -43,7 +43,8 @@ SocketPoll::SocketPoll(const std::string& threadName)
: _name(threadName), : _name(threadName),
_stop(false), _stop(false),
_threadStarted(false), _threadStarted(false),
_threadFinished(false) _threadFinished(false),
_owner(std::this_thread::get_id())
{ {
// Create the wakeup fd. // Create the wakeup fd.
if (::pipe2(_wakeup, O_CLOEXEC | O_NONBLOCK) == -1) if (::pipe2(_wakeup, O_CLOEXEC | O_NONBLOCK) == -1)
@ -56,9 +57,11 @@ SocketPoll::SocketPoll(const std::string& threadName)
getWakeupsArray().push_back(_wakeup[1]); getWakeupsArray().push_back(_wakeup[1]);
} }
#if ENABLE_DEBUG
_owner = std::this_thread::get_id(); _owner = std::this_thread::get_id();
LOG_DBG("Thread affinity of " << _name << " set to 0x" << LOG_DBG("Thread affinity of " << _name << " set to 0x" <<
std::hex << _owner << "." << std::dec); std::hex << _owner << "." << std::dec);
#endif
} }
SocketPoll::~SocketPoll() SocketPoll::~SocketPoll()

View file

@ -47,15 +47,14 @@ public:
Socket() : Socket() :
_fd(socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0)), _fd(socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0)),
_sendBufferSize(DefaultSendBufferSize) _sendBufferSize(DefaultSendBufferSize),
_owner(std::this_thread::get_id())
{ {
init(); init();
} }
virtual ~Socket() virtual ~Socket()
{ {
// TODO: Should we shutdown here or up to the client?
LOG_TRC("#" << getFD() << " Socket dtor."); LOG_TRC("#" << getFD() << " Socket dtor.");
// Doesn't block on sockets; no error handling needed. // Doesn't block on sockets; no error handling needed.
@ -231,11 +230,13 @@ protected:
_sendBufferSize = DefaultSendBufferSize; _sendBufferSize = DefaultSendBufferSize;
#if ENABLE_DEBUG #if ENABLE_DEBUG
_owner = std::this_thread::get_id(); _owner = std::this_thread::get_id();
LOG_DBG("#" << _fd << " Thread affinity set to 0x" << std::hex << _owner << "." << std::dec); LOG_DBG("#" << _fd << " Thread affinity set to 0x" << std::hex <<
_owner << "." << std::dec);
const int oldSize = getSocketBufferSize(); const int oldSize = getSocketBufferSize();
setSocketBufferSize(0); setSocketBufferSize(0);
LOG_TRC("#" << _fd << ": Buffer size: " << getSendBufferSize() << " (was " << oldSize << ")"); LOG_TRC("#" << _fd << ": Buffer size: " << getSendBufferSize() <<
" (was " << oldSize << ")");
#endif #endif
} }
@ -323,8 +324,8 @@ public:
rc = ::poll(&_pollFds[0], size + 1, std::max(timeoutMaxMs,0)); rc = ::poll(&_pollFds[0], size + 1, std::max(timeoutMaxMs,0));
} }
while (rc < 0 && errno == EINTR); while (rc < 0 && errno == EINTR);
LOG_TRC("Poll completed with " << rc << " live polls max (" << timeoutMaxMs << "ms)" LOG_TRC("Poll completed with " << rc << " live polls max (" <<
<< ((rc==0) ? "(timedout)" : "")); timeoutMaxMs << "ms)" << ((rc==0) ? "(timedout)" : ""));
// Fire the callback and remove dead fds. // Fire the callback and remove dead fds.
std::chrono::steady_clock::time_point newNow = std::chrono::steady_clock::time_point newNow =

View file

@ -1322,9 +1322,7 @@ static std::shared_ptr<ClientSession> createNewClientSession(const WebSocketHand
// In case of WOPI, if this session is not set as readonly, it might be set so // In case of WOPI, if this session is not set as readonly, it might be set so
// later after making a call to WOPI host which tells us the permission on files // later after making a call to WOPI host which tells us the permission on files
// (UserCanWrite param). // (UserCanWrite param).
auto session = std::make_shared<ClientSession>(id, docBroker, uriPublic, isReadOnly); return std::make_shared<ClientSession>(id, docBroker, uriPublic, isReadOnly);
return session;
} }
catch (const std::exception& exc) catch (const std::exception& exc)
{ {