[Libreoffice-commits] online.git: Branch 'private/Ashod/nonblocking' - 6 commits - net/loolnb.cpp net/socket.hpp wsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Tue Feb 21 04:47:27 UTC 2017
net/loolnb.cpp | 25 +++++++++++++++----------
net/socket.hpp | 13 +++++--------
wsd/LOOLWSD.cpp | 1 +
3 files changed, 21 insertions(+), 18 deletions(-)
New commits:
commit 41c99e9132fc5d47314a804ba9333ef0dc47b4d1
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Feb 20 23:43:05 2017 -0500
nb: throw when we run out of resources
Change-Id: I12fd236bffd50dbf7a1bb9eb4c665ea9d9d545e4
diff --git a/net/socket.hpp b/net/socket.hpp
index e8782ea..7ce7378 100644
--- a/net/socket.hpp
+++ b/net/socket.hpp
@@ -157,10 +157,7 @@ public:
// Create the wakeup fd.
if (::pipe2(_wakeup, O_CLOEXEC | O_NONBLOCK) == -1)
{
- // FIXME: Can't have wakeup pipe, should we exit?
- // FIXME: running out of sockets should be a case we handle elegantly here - and also in our accept / ClientSocket creation I guess.
- _wakeup[0] = -1;
- _wakeup[1] = -1;
+ throw std::runtime_error("Failed to allocate pipe for SocketPoll waking.");
}
}
commit 6bf8e544af843626774f36efb8d1b9422d260d30
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Feb 20 23:28:20 2017 -0500
nb: read to the end of the full buffer
Change-Id: I94264f748ac974f636ab6d21a5ccbb77532136f6
diff --git a/net/socket.hpp b/net/socket.hpp
index 1c16124..e8782ea 100644
--- a/net/socket.hpp
+++ b/net/socket.hpp
@@ -339,19 +339,18 @@ public:
// TODO: Cap the buffer size, lest we grow beyond control.
do
{
- len = readData(buf, sizeof(buf) - 1);
+ len = readData(buf, sizeof(buf));
}
while (len < 0 && errno == EINTR);
if (len > 0)
{
- assert (len < ssize_t(sizeof(buf)));
+ assert (len <= ssize_t(sizeof(buf)));
_inBuffer.insert(_inBuffer.end(), &buf[0], &buf[len]);
- continue;
}
// else poll will handle errors.
}
- while (len == (sizeof(buf) - 1));
+ while (len == (sizeof(buf)));
return len != 0; // zero is eof / clean socket close.
}
commit 8aa0ce9168f6441b081f2b2bb359bf37caea527d
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Feb 20 23:18:54 2017 -0500
nb: assert on trying to write empty data
Change-Id: Ie18b5d00acf769a112b47d45f8c7783fb5746acf
diff --git a/net/socket.hpp b/net/socket.hpp
index d9b5842..1c16124 100644
--- a/net/socket.hpp
+++ b/net/socket.hpp
@@ -359,6 +359,7 @@ public:
/// Override to write data out to socket.
virtual void writeOutgoingData()
{
+ assert(!_outBuffer.empty());
while (!_outBuffer.empty())
{
ssize_t len;
commit 8617d456e441887b497505d76a761e8ce260eb77
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Feb 20 23:13:11 2017 -0500
nb: fixme for HTTP handling
Change-Id: I4364e2e4cd3233134c026890ce690abaf46b961d
diff --git a/net/loolnb.cpp b/net/loolnb.cpp
index ce7872f..a25007d 100644
--- a/net/loolnb.cpp
+++ b/net/loolnb.cpp
@@ -60,8 +60,11 @@ public:
req.read(message);
// if we succeeded - remove that from our input buffer
- // An HTTP request is either parsed completely and successfully, or not.
- // We can't have partial read, even though Poco seems to not report full read.
+ // FIXME: We should check if this is GET or POST. For GET, we only
+ // can have a single request (headers only). For POST, we can/should
+ // use Poco HTMLForm to parse the post message properly.
+ // Otherwise, we should catch exceptions from the previous read/parse
+ // and assume we don't have sufficient data, so we wait some more.
T::_inBuffer.clear();
StringTokenizer tokens(req.getURI(), "/?");
commit c79a6a99eabd6598fea8bd1d0f5339c751ab0804
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Feb 20 21:58:59 2017 -0500
nb: comment to replace ConsoleCertificateHandler
ConsoleCertificateHandler will block on stdin
when a certificate error occures. This is hardly
helpful to users. Although in a server environment
this is likely to go to the journal, we should
properly log it and shutdown, rather than hang
waiting for the unlikely console input.
Change-Id: I54bb38ec60f443c579ef20dbb759941fae182e5b
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index c910f98..9b475e6 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2011,6 +2011,7 @@ void LOOLWSD::initializeSSL()
// Don't ask clients for certificate
sslParams.verificationMode = Poco::Net::Context::VERIFY_NONE;
+ // FIXME: ConsoleCertificateHandler will block on stdin upon error!
Poco::SharedPtr<Poco::Net::PrivateKeyPassphraseHandler> consoleHandler = new Poco::Net::KeyConsoleHandler(true);
Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> invalidCertHandler = new Poco::Net::ConsoleCertificateHandler(true);
commit e0fddee17d5182d07fe6ef8a454b70210aeaad65
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Feb 20 21:35:58 2017 -0500
nb: safer endianness conversion
Change-Id: I63977e6e99119fef2a61911d07d645a606d4c443
diff --git a/net/loolnb.cpp b/net/loolnb.cpp
index b86e4e7..ce7872f 100644
--- a/net/loolnb.cpp
+++ b/net/loolnb.cpp
@@ -221,19 +221,21 @@ public:
{
header[1] |= 126;
T::_outBuffer.push_back((char)header[1]);
- char* p = reinterpret_cast<char*>(&len);
- T::_outBuffer.push_back(p[1]);
- T::_outBuffer.push_back(p[0]);
+ T::_outBuffer.push_back(static_cast<char>((len >> 8) & 0xff));
+ T::_outBuffer.push_back(static_cast<char>((len >> 0) & 0xff));
}
else
{
header[1] |= 127;
T::_outBuffer.push_back((char)header[1]);
- char* p = reinterpret_cast<char*>(&len);
- for (int i = 7; i >= 0; --i)
- {
- T::_outBuffer.push_back(p[i]);
- }
+ T::_outBuffer.push_back(static_cast<char>((len >> 56) & 0xff));
+ T::_outBuffer.push_back(static_cast<char>((len >> 48) & 0xff));
+ T::_outBuffer.push_back(static_cast<char>((len >> 40) & 0xff));
+ T::_outBuffer.push_back(static_cast<char>((len >> 32) & 0xff));
+ T::_outBuffer.push_back(static_cast<char>((len >> 24) & 0xff));
+ T::_outBuffer.push_back(static_cast<char>((len >> 16) & 0xff));
+ T::_outBuffer.push_back(static_cast<char>((len >> 8) & 0xff));
+ T::_outBuffer.push_back(static_cast<char>((len >> 0) & 0xff));
}
// FIXME: pick random number and mask in the outbuffer etc.
More information about the Libreoffice-commits
mailing list