net/socket.hpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
New commits: commit dca41f199451956d5f89535cb1042aceee5df79b Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun Feb 19 14:47:25 2017 -0500 nb: improved poll handler We now always read new data, because SSL might need to process internal buffers, and call the app message handler as long as it keeps consuming data. Finally, we write when we have data to flush, even if we didn't get POLLOUT event, because SSL might need to do handshake, which is handled by the write handler. Change-Id: I909333c3a0492b0830044d51ae478ac5981b1d90 Reviewed-on: https://gerrit.libreoffice.org/34448 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/net/socket.hpp b/net/socket.hpp index 5f63818..cea6fac 100644 --- a/net/socket.hpp +++ b/net/socket.hpp @@ -293,24 +293,31 @@ private: class BufferingSocket : public Socket { public: + + /// Called when a polling event is received. + /// @events is the mask of events that triggered the wake. HandleResult handlePoll(const int events) override { + // FIXME: need to close input, but not output (?) bool closeSocket = false; - // FIXME: need to close input, but not output (?) - if (events & POLLIN) + // Always try to read. + closeSocket = !readIncomingData(); + + // If we have data, allow the app to consume. + size_t oldSize = 0; + while (!_inBuffer.empty() && oldSize != _inBuffer.size()) { - size_t oldSize = _inBuffer.size(); - closeSocket = !readIncomingData(); - while (oldSize != _inBuffer.size()) - { - oldSize = _inBuffer.size(); - handleIncomingMessage(); - } + oldSize = _inBuffer.size(); + handleIncomingMessage(); } - if (events & POLLOUT) + // SSL might want to do handshake, + // even if we have no data to write. + if ((events & POLLOUT) || !_outBuffer.empty()) + { writeOutgoingData(); + } if (events & (POLLHUP | POLLERR | POLLNVAL)) closeSocket = true; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits