[Libreoffice-commits] online.git: net/Socket.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Mar 13 04:24:56 UTC 2017
net/Socket.hpp | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
New commits:
commit 862d7a07342f1caad5a9474c480b06585c813bea
Author: Ashod Nakashian <ashod.nakashian at 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 <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at 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)
{
More information about the Libreoffice-commits
mailing list