From ad0f0618fa2ca13d7b916f22eccc5ba3201482cb Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 14 May 2020 18:49:39 +0200 Subject: Change streams to be asynchronous Major restructuring of how streams work. Neither input nor output streams are now blocking. This avoids stalling the rest of the client or server when a peer is slow or unresponsive. Note that this puts an extra burden on users of streams to make sure they are allowed to do their work once the underlying transports are ready (e.g. monitoring fds). --- tests/perf/decperf.cxx | 2 ++ tests/perf/encperf.cxx | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/perf/decperf.cxx b/tests/perf/decperf.cxx index e1307070..a6c65a22 100644 --- a/tests/perf/decperf.cxx +++ b/tests/perf/decperf.cxx @@ -102,6 +102,8 @@ void DummyOutStream::flush() void DummyOutStream::overrun(size_t needed) { flush(); + if (avail() < needed) + throw rdr::Exception("Insufficient dummy output buffer"); } CConn::CConn(const char *filename) diff --git a/tests/perf/encperf.cxx b/tests/perf/encperf.cxx index 6bcb6f74..41c309c1 100644 --- a/tests/perf/encperf.cxx +++ b/tests/perf/encperf.cxx @@ -95,7 +95,7 @@ public: virtual void setCursor(int, int, const rfb::Point&, const rdr::U8*); virtual void framebufferUpdateStart(); virtual void framebufferUpdateEnd(); - virtual void dataRect(const rfb::Rect&, int); + virtual bool dataRect(const rfb::Rect&, int); virtual void setColourMapEntries(int, int, rdr::U16*); virtual void bell(); virtual void serverCutText(const char*); @@ -159,6 +159,8 @@ void DummyOutStream::flush() void DummyOutStream::overrun(size_t needed) { flush(); + if (avail() < needed) + throw rdr::Exception("Insufficient dummy output buffer"); } CConn::CConn(const char *filename) @@ -241,12 +243,15 @@ void CConn::framebufferUpdateEnd() encodeTime += getCpuCounter(); } -void CConn::dataRect(const rfb::Rect &r, int encoding) +bool CConn::dataRect(const rfb::Rect &r, int encoding) { - CConnection::dataRect(r, encoding); + if (!CConnection::dataRect(r, encoding)) + return false; if (encoding != rfb::encodingCopyRect) // FIXME updates.add_changed(rfb::Region(r)); + + return true; } void CConn::setColourMapEntries(int, int, rdr::U16*) -- cgit v1.2.3