diff options
author | Pierre Ossman <ossman@cendio.se> | 2020-05-14 18:49:39 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2020-05-21 12:59:02 +0200 |
commit | ad0f0618fa2ca13d7b916f22eccc5ba3201482cb (patch) | |
tree | 55b84c52f8ab0e7ebe672458471e4577afddc1b9 /tests | |
parent | c0dac220de0186a879f1f71966a2848000f69a48 (diff) | |
download | tigervnc-ad0f0618fa2ca13d7b916f22eccc5ba3201482cb.tar.gz tigervnc-ad0f0618fa2ca13d7b916f22eccc5ba3201482cb.zip |
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).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/perf/decperf.cxx | 2 | ||||
-rw-r--r-- | tests/perf/encperf.cxx | 11 |
2 files changed, 10 insertions, 3 deletions
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*) |