libreoffice-online/net
Ashod Nakashian f6ca40b4fd wsd: do not close the socket while have data to read
The last burst of data arrives with POLLHUP.
If during the read we hit any errors, including
EAGAIN, for whatever reason, we may lose the
data if we don't attempt reading again later.

The only way to guarantee that we do not have
any more data to read, when we get POLLHUP,
is to poll until we either get no POLLIN or
read returns 0 indicating the socket is closed,

Oddly, read(2) sometimes returns 0 without
POLLHUP ever being set, and sometimes we
do get POLLHUP while POLLIN still set. This
implies that poll and read aren't consistent
in how they detect and report the close
condition. Luckily, with this patch we can
handle all cases without any complications.

This was caught through simulateSocketError,
which when it injects EAGAIN on the very
last read, when the socket is closed, causes
error as the response is partially or
completely lost (because we never read it).

The behavioral change should only be
observable with EnableExperimental.

Change-Id: I77260f98d5dd5050c5f9b202b9effd501191336b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2022-04-14 10:48:45 +01:00
..
Buffer.hpp Buffer: remove _size member and calculate it from _offset as needed. 2021-11-30 09:32:45 +00:00
clientnb.cpp
DelaySocket.cpp
DelaySocket.hpp
FakeSocket.cpp
FakeSocket.hpp
HttpHelper.cpp rename: remaining lool->cool changes 2021-11-18 14:14:11 +01:00
HttpHelper.hpp
HttpRequest.cpp
HttpRequest.hpp wsd: use STATE_ENUM for http 2022-04-06 18:33:45 -04:00
NetUtil.cpp
NetUtil.hpp
ServerSocket.hpp wsd: reduce noisy logs 2022-02-04 10:26:49 -05:00
Socket.cpp wsd: logging and minor cosmetics 2022-04-06 18:33:45 -04:00
Socket.hpp wsd: do not close the socket while have data to read 2022-04-14 10:48:45 +01:00
Ssl.cpp wsd: enforce TLSv1.2 as the minimum acceptable version 2022-01-10 21:26:38 +01:00
Ssl.hpp
SslSocket.hpp wsd: test SSL hostname 2022-04-01 10:33:55 +01:00
WebSocketHandler.hpp Validate as utf-8 all Websocket text messages in debug mode. 2022-04-04 20:46:11 +01:00
WebSocketSession.hpp rename: remaining lool->cool changes 2021-11-18 14:14:11 +01:00