net/Socket.hpp | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-)
New commits: commit 862d7a07342f1caad5a9474c480b06585c813bea Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun Mar 12 22:29:30 2017 -0400 wsd: write as many messages to socket as possible Change-Id: Ie2702ea68dd1ae6200fcc304224dea34fc94544f Reviewed-on: https://gerrit.libreoffice.org/35123 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 4fe334b..01f985c 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -682,26 +682,35 @@ protected: _socketHandler->handleIncomingMessage(); } - // If we have space for writing and that was requested - if ((events & POLLOUT) && _outBuffer.empty()) - _socketHandler->performWrites(); + do + { + // If we have space for writing and that was requested + if ((events & POLLOUT) && _outBuffer.empty()) + _socketHandler->performWrites(); - // perform the shutdown if we have sent everything. - if (_shutdownSignalled && _outBuffer.empty()) - closeConnection(); + // perform the shutdown if we have sent everything. + if (_shutdownSignalled && _outBuffer.empty()) + { + closeConnection(); + closed = true; + break; + } - // SSL might want to do handshake, - // even if we have no data to write. - if ((events & POLLOUT) || !_outBuffer.empty()) - { - std::unique_lock<std::mutex> lock(_writeMutex, std::defer_lock); + oldSize = _outBuffer.size(); - // The buffer could have been flushed while we waited for the lock. - if (lock.try_lock() && !_outBuffer.empty()) - writeOutgoingData(); + // Write if we can and have data to write. + if ((events & POLLOUT) || !_outBuffer.empty()) + { + std::unique_lock<std::mutex> lock(_writeMutex, std::defer_lock); - closed = closed || (errno == EPIPE); + // The buffer could have been flushed while we waited for the lock. + if (lock.try_lock() && !_outBuffer.empty()) + writeOutgoingData(); + + closed = closed || (errno == EPIPE); + } } + while (oldSize != _outBuffer.size()); if (closed) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits