diff options
author | Pierre Ossman <ossman@cendio.se> | 2024-12-17 11:02:19 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2024-12-17 12:20:07 +0100 |
commit | 892832531627e16e61f6ccc602e1995cf065bba7 (patch) | |
tree | 9eac3ba8876850be3cb8ca0fbd579ba16234a4bf /common/rfb/CSecurityRSAAES.cxx | |
parent | 38ff2bdb913edafa26ebd9ba8ec3c94dc654d47c (diff) | |
download | tigervnc-892832531627e16e61f6ccc602e1995cf065bba7.tar.gz tigervnc-892832531627e16e61f6ccc602e1995cf065bba7.zip |
Always flush sockets on shutdown()
The system shutdown() function doesn't drop buffered data, so neither
should we.
We had one fix in place, but that didn't cover all cases. Move this
handling to all socket like classes we have.
Diffstat (limited to 'common/rfb/CSecurityRSAAES.cxx')
-rw-r--r-- | common/rfb/CSecurityRSAAES.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/common/rfb/CSecurityRSAAES.cxx b/common/rfb/CSecurityRSAAES.cxx index 56e1d702..0985d0f2 100644 --- a/common/rfb/CSecurityRSAAES.cxx +++ b/common/rfb/CSecurityRSAAES.cxx @@ -55,6 +55,8 @@ const int MaxKeyLength = 8192; using namespace rfb; +static LogWriter vlog("CSecurityRSAAES"); + CSecurityRSAAES::CSecurityRSAAES(CConnection* cc_, uint32_t _secType, int _keySize, bool _isAllEncrypted) : CSecurity(cc_), state(ReadPublicKey), @@ -74,6 +76,19 @@ CSecurityRSAAES::~CSecurityRSAAES() void CSecurityRSAAES::cleanup() { + if (raos) { + try { + if (raos->hasBufferedData()) { + raos->cork(false); + raos->flush(); + if (raos->hasBufferedData()) + vlog.error("Failed to flush remaining socket data on close"); + } + } catch (std::exception& e) { + vlog.error("Failed to flush remaining socket data on close: %s", e.what()); + } + } + if (serverKeyN) delete[] serverKeyN; if (serverKeyE) |