Skip to content

Commit

Permalink
#2975 add an optional flush flag to the xpra chunk packet header
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@28117 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Dec 10, 2020
1 parent 3669fe6 commit 06ff1a5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/html5/js/Protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ XpraProtocol.prototype.do_process_receive_queue = function() {
proto_flags = proto_flags & ~0x2;
}

if (proto_flags & 0x8) {
//this flag is unused client-side, so just ignore it:
proto_flags = proto_flags & ~0x8;
}

if (proto_flags > 1) {
this.protocol_error("we can't handle this protocol flag yet: "+proto_flags);
return;
Expand Down
1 change: 1 addition & 0 deletions src/xpra/net/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ConnectionClosedException(Exception):
pass

MAX_PACKET_SIZE = envint("XPRA_MAX_PACKET_SIZE", 16*1024*1024)
FLUSH_HEADER = envbool("XPRA_FLUSH_HEADER", True)

SOCKET_TYPES = ("tcp", "ws", "wss", "ssl", "ssh", "rfb", "vsock", "udp")

Expand Down
1 change: 1 addition & 0 deletions src/xpra/net/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
FLAGS_RENCODE = 0x1
FLAGS_CIPHER = 0x2
FLAGS_YAML = 0x4
FLAGS_FLUSH = 0x8

#compression flags are carried in the "level" field,
#the low bits contain the compression level, the high bits the compression algo:
Expand Down
5 changes: 4 additions & 1 deletion src/xpra/net/net_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# This file is part of Xpra.
# Copyright (C) 2013-2019 Antoine Martin <[email protected]>
# Copyright (C) 2013-2020 Antoine Martin <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand Down Expand Up @@ -372,6 +372,9 @@ def get_network_caps() -> dict:
"compressors" : get_enabled_compressors(),
"encoders" : get_enabled_encoders(),
}
from xpra.net.common import FLUSH_HEADER
if FLUSH_HEADER:
caps["flush"] = True
caps.update(get_crypto_caps())
caps.update(get_compression_caps())
caps.update(get_packet_encoding_caps())
Expand Down
14 changes: 12 additions & 2 deletions src/xpra/net/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
from xpra.os_util import memoryview_to_bytes, strtobytes, bytestostr, hexstr, monotonic_time
from xpra.util import repr_ellipsized, ellipsizer, csv, envint, envbool, typedict
from xpra.make_thread import make_thread, start_thread
from xpra.net.common import ConnectionClosedException, may_log_packet, MAX_PACKET_SIZE #@UndefinedVariable (pydev false positive)
from xpra.net.common import (
ConnectionClosedException, may_log_packet,
MAX_PACKET_SIZE, FLUSH_HEADER,
)
from xpra.net.bytestreams import ABORT
from xpra.net import compression
from xpra.net.compression import (
Expand All @@ -29,7 +32,7 @@
decode, sanity_checks as packet_encoding_sanity_checks,
InvalidPacketEncodingException,
)
from xpra.net.header import unpack_header, pack_header, FLAGS_CIPHER, FLAGS_NOHEADER, HEADER_SIZE
from xpra.net.header import unpack_header, pack_header, FLAGS_CIPHER, FLAGS_NOHEADER, FLAGS_FLUSH, HEADER_SIZE
from xpra.net.crypto import get_encryptor, get_decryptor, pad, INITIAL_PADDING
from xpra.log import Logger

Expand Down Expand Up @@ -165,6 +168,7 @@ def __init__(self, scheduler, conn, process_packet_cb, get_packet_cb=None):
self.abs_max_packet_size = 256*1024*1024
self.large_packets = [b"hello", b"window-metadata", b"sound-data", b"notify_show", b"setting-change", b"shell-reply"]
self.send_aliases = {}
self.send_flush_flag = False
self.receive_aliases = {}
self._log_stats = None #None here means auto-detect
self._closed = False
Expand Down Expand Up @@ -264,13 +268,16 @@ def accept(self):
def parse_remote_caps(self, caps : typedict):
for k,v in caps.dictget("aliases", {}).items():
self.send_aliases[bytestostr(k)] = v
if FLUSH_HEADER:
self.send_flush_flag = caps.boolget("flush", False)

def get_info(self, alias_info=True) -> dict:
info = {
"large_packets" : tuple(bytestostr(x) for x in self.large_packets),
"compression_level" : self.compression_level,
"max_packet_size" : self.max_packet_size,
"aliases" : USE_ALIASES,
"flush" : self.send_flush_flag,
}
c = self.compressor
if c:
Expand Down Expand Up @@ -420,6 +427,9 @@ def _add_chunks_to_queue(self, packet_type, chunks, start_send_cb=None, end_send
log("sending %s bytes without header", payload_size)
items.append(data)
else:
#if the other end can use this flag, expose it:
if self.send_flush_flag and not more and index==0:
proto_flags |= FLAGS_FLUSH
#the xpra packet header:
#(WebSocketProtocol may also add a websocket header too)
header = self.make_chunk_header(packet_type, proto_flags, level, index, payload_size)
Expand Down

0 comments on commit 06ff1a5

Please sign in to comment.