Browse Source

Merge branch 'cork' of https://github.com/CendioOssman/tigervnc

tags/v1.12.90
Pierre Ossman 1 year ago
parent
commit
8b9cc06c9a

+ 1
- 1
common/rdr/OutStream.h View File

@@ -113,7 +113,7 @@ namespace rdr {

// cork() requests that the stream coalesces flushes in an efficient way

virtual void cork(bool enable) { corked = enable; flush(); }
virtual void cork(bool enable) { corked = enable; if (!enable) flush(); }

// getptr() and setptr() are "dirty" methods which allow you direct access
// to the buffer. This is useful for a stream which is a wrapper around an

+ 6
- 1
common/rdr/TLSOutStream.cxx View File

@@ -124,13 +124,18 @@ void TLSOutStream::cork(bool enable)

void TLSOutStream::overrun(size_t needed)
{
bool oldCorked;

if (needed > bufSize)
throw Exception("TLSOutStream overrun: buffer size exceeded");

// A cork might prevent the flush, so disable it temporarily
oldCorked = corked;
corked = false;

flush();
corked = true;

corked = oldCorked;
}

size_t TLSOutStream::writeTLS(const U8* data, size_t length)

+ 7
- 1
common/rdr/ZlibOutStream.cxx View File

@@ -129,11 +129,17 @@ void ZlibOutStream::overrun(size_t needed)
checkCompressionLevel();

while (avail() < needed) {
bool oldCorked;

// use corked to make zlib a bit more efficient since we're not trying
// to end the stream here, just make some room

oldCorked = corked;
corked = true;

flush();
corked = false;

corked = oldCorked;
}
}


+ 20
- 4
common/rfb/CMsgReader.cxx View File

@@ -341,17 +341,33 @@ bool CMsgReader::readExtendedClipboard(rdr::S32 len)

lengths[num] = zis.readU32();

if (!zis.hasData(lengths[num]))
throw Exception("Extended clipboard decode error");

if (lengths[num] > (size_t)maxCutText) {
vlog.error("Extended clipboard data too long (%d bytes) - ignoring",
(unsigned)lengths[num]);
zis.skip(lengths[num]);

// Slowly (safely) drain away the data
while (lengths[num] > 0) {
size_t chunk;

if (!zis.hasData(1))
throw Exception("Extended clipboard decode error");

chunk = zis.avail();
if (chunk > lengths[num])
chunk = lengths[num];

zis.skip(chunk);
lengths[num] -= chunk;
}

flags &= ~(1 << i);

continue;
}

if (!zis.hasData(lengths[num]))
throw Exception("Extended clipboard decode error");

buffers[num] = new rdr::U8[lengths[num]];
zis.readBytes(buffers[num], lengths[num]);
num++;

+ 20
- 4
common/rfb/SMsgReader.cxx View File

@@ -380,17 +380,33 @@ bool SMsgReader::readExtendedClipboard(rdr::S32 len)

lengths[num] = zis.readU32();

if (!zis.hasData(lengths[num]))
throw Exception("Extended clipboard decode error");

if (lengths[num] > (size_t)maxCutText) {
vlog.error("Extended clipboard data too long (%d bytes) - ignoring",
(unsigned)lengths[num]);
zis.skip(lengths[num]);

// Slowly (safely) drain away the data
while (lengths[num] > 0) {
size_t chunk;

if (!zis.hasData(1))
throw Exception("Extended clipboard decode error");

chunk = zis.avail();
if (chunk > lengths[num])
chunk = lengths[num];

zis.skip(chunk);
lengths[num] -= chunk;
}

flags &= ~(1 << i);

continue;
}

if (!zis.hasData(lengths[num]))
throw Exception("Extended clipboard decode error");

buffers[num] = new rdr::U8[lengths[num]];
zis.readBytes(buffers[num], lengths[num]);
num++;

+ 2
- 3
vncviewer/CConn.cxx View File

@@ -247,7 +247,7 @@ void CConn::socketEvent(FL_SOCKET fd, void *data)
// We might have been called to flush unwritten socket data
cc->sock->outStream().flush();

cc->sock->outStream().cork(true);
cc->getOutStream()->cork(true);

// processMsg() only processes one message, so we need to loop
// until the buffers are empty or things will stall.
@@ -263,8 +263,7 @@ void CConn::socketEvent(FL_SOCKET fd, void *data)
break;
}

cc->sock->outStream().cork(false);
cc->sock->outStream().flush();
cc->getOutStream()->cork(false);
} catch (rdr::EndOfStream& e) {
vlog.info("%s", e.str());
if (!cc->desktop) {

Loading…
Cancel
Save