diff options
author | Pierre Ossman <ossman@cendio.se> | 2020-05-18 19:40:49 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2020-05-21 11:34:22 +0200 |
commit | d45082a591de99655ee421849ce67f8d6e474569 (patch) | |
tree | 61ec822cce4b3c935d705a000b2354f48e09a766 | |
parent | 585089797f7f79a5f521b54e659d1781246e40c1 (diff) | |
download | tigervnc-d45082a591de99655ee421849ce67f8d6e474569.tar.gz tigervnc-d45082a591de99655ee421849ce67f8d6e474569.zip |
Flush data on close
There might be some final handshake data that is still stuck in the
buffers, so make a best effort attempt at getting it to the client.
-rw-r--r-- | common/rfb/VNCSConnectionST.cxx | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index 39efb6c6..a00ae435 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -114,6 +114,17 @@ void VNCSConnectionST::close(const char* reason) else vlog.debug("second close: %s (%s)", peerEndpoint.buf, reason); + try { + if (sock->outStream().bufferUsage() > 0) { + sock->cork(false); + sock->outStream().flush(); + if (sock->outStream().bufferUsage() > 0) + vlog.error("Failed to flush remaining socket data on close"); + } + } catch (rdr::Exception& e) { + vlog.error("Failed to flush remaining socket data on close: %s", e.str()); + } + // Just shutdown the socket and mark our state as closing. Eventually the // calling code will call VNCServerST's removeSocket() method causing us to // be deleted. |