Skip to content

Commit

Permalink
#1912: add switch for turning off bandwidth detection
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@19878 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 8, 2018
1 parent 5dc89c8 commit 4f210c9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/xpra/client/mixins/network_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self):

#bandwidth
self.bandwidth_limit = 0
self.bandwidth_detection = True
self.server_bandwidth_limit_change = False
self.server_bandwidth_limit = 0
self.server_session_name = None
Expand All @@ -66,6 +67,7 @@ def __init__(self):
def init(self, opts):
self.pings = opts.pings
self.bandwidth_limit = parse_with_unit("bandwidth-limit", opts.bandwidth_limit)
self.bandwidth_detection = opts.bandwidth_detection
bandwidthlog("init bandwidth_limit=%s", self.bandwidth_limit)


Expand Down Expand Up @@ -107,6 +109,7 @@ def get_caps(self):
bandwidthlog("bandwidth-limit capability=%s", bandwidth_limit)
if bandwidth_limit>0:
caps["bandwidth-limit"] = bandwidth_limit
caps["bandwidth-detection"] = self.bandwidth_detection
return caps

def parse_server_capabilities(self):
Expand Down
6 changes: 4 additions & 2 deletions src/xpra/scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ def may_create_user_config(xpra_conf_filename=DEFAULT_XPRA_CONF_FILENAME):
"global-menus" : bool,
"forward-xdg-open" : bool,
"modal-windows" : bool,
"bandwidth-detection" : bool,
#arrays of strings:
"pulseaudio-configure-commands" : list,
"socket-dirs" : list,
Expand Down Expand Up @@ -634,7 +635,7 @@ def may_create_user_config(xpra_conf_filename=DEFAULT_XPRA_CONF_FILENAME):
#keep track of the options added since v1,
#so we can generate command lines that work with older supported versions:
OPTIONS_ADDED_SINCE_V1 = ["attach", "open-files", "open-url", "pixel-depth", "uid", "gid", "chdir", "min-port", "rfb-upgrade", "bandwidth-limit",
"forward-xdg-open", "modal-windows",
"forward-xdg-open", "modal-windows", "bandwidth-detection",
]

CLIENT_OPTIONS = ["title", "username", "password", "session-name",
Expand Down Expand Up @@ -694,7 +695,7 @@ def may_create_user_config(xpra_conf_filename=DEFAULT_XPRA_CONF_FILENAME):
"system-tray", "sharing", "lock", "windows", "webcam", "html",
"terminate-children", "exit-with-children", "exit-with-client",
"av-sync", "global-menus",
"forward-xdg-open", "modal-windows",
"forward-xdg-open", "modal-windows", "bandwidth-detection",
"printing", "file-transfer", "open-command", "open-files", "open-url", "start-new-commands",
"mmap", "mmap-group", "mdns",
"auth", "vsock-auth", "tcp-auth", "udp-auth", "ws-auth", "wss-auth", "ssl-auth", "rfb-auth",
Expand Down Expand Up @@ -960,6 +961,7 @@ def addtrailingslash(v):
"global-menus" : True,
"forward-xdg-open" : True,
"modal-windows" : True,
"bandwidth-detection" : True,
"pulseaudio-configure-commands" : [" ".join(x) for x in DEFAULT_PULSEAUDIO_CONFIGURE_COMMANDS],
"socket-dirs" : [],
"remote-xpra" : get_remote_run_xpra_scripts(),
Expand Down
4 changes: 4 additions & 0 deletions src/xpra/scripts/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ def ignore(defaults):
group.add_option("--bandwidth-limit", action="store",
dest="bandwidth_limit", default=defaults.bandwidth_limit,
help="Limit the bandwidth used. The value is specified in bits per second, use the value '0' to disable restrictions. Default: '%default'.")
legacy_bool_parse("bandwidth-detection")
group.add_option("--bandwidth-detection", action="store",
dest="bandwidth_detection", default=defaults.bandwidth_detection,
help="Automatically detect runtime bandwidth limits. Default: '%default'.")
replace_option("--readwrite", "--readonly=no")
replace_option("--readonly", "--readonly=yes")
group.add_option("--readonly", action="store", metavar="yes|no",
Expand Down
4 changes: 3 additions & 1 deletion src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ def init(self, opts):
self.lock = opts.lock
self.idle_timeout = opts.idle_timeout
self.av_sync = opts.av_sync
self.bandwidth_detection = opts.bandwidth_detection
log.warn("bandwidth_detection=%s", self.bandwidth_detection)


def setup(self):
Expand Down Expand Up @@ -318,7 +320,7 @@ def drop_client(reason="unknown", *args):
self.session_name, self,
self.idle_add, self.timeout_add, self.source_remove,
self.setting_changed,
self._socket_dir, self.unix_socket_paths, not is_request, self.bandwidth_limit,
self._socket_dir, self.unix_socket_paths, not is_request, self.bandwidth_limit, self.bandwidth_detection,
)
log("process_hello clientconnection=%s", ss)
try:
Expand Down
11 changes: 8 additions & 3 deletions src/xpra/server/source/client_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class ClientConnection(ClientConnectionClass):
def __init__(self, protocol, disconnect_cb, session_name, server,
idle_add, timeout_add, source_remove,
setting_changed,
socket_dir, unix_socket_paths, log_disconnect, bandwidth_limit,
socket_dir, unix_socket_paths, log_disconnect, bandwidth_limit, bandwidth_detection,
):
global counter
self.counter = counter.increase()
Expand Down Expand Up @@ -146,6 +146,7 @@ def __init__(self, protocol, disconnect_cb, session_name, server,
self.setting_changed = setting_changed
# network constraints:
self.server_bandwidth_limit = bandwidth_limit
self.bandwidth_detection = bandwidth_detection

#these statistics are shared by all WindowSource instances:
self.statistics = GlobalPerformanceStatistics()
Expand Down Expand Up @@ -197,6 +198,8 @@ def close(self):


def update_bandwidth_limits(self):
if not self.bandwidth_detection:
return
mmap_size = getattr(self, "mmap_size", 0)
if mmap_size>0:
return
Expand All @@ -217,7 +220,7 @@ def update_bandwidth_limits(self):
bandwidthlog("update_bandwidth_limits() bandwidth_limit=%s, soft bandwidth limit=%s", self.bandwidth_limit, bandwidth_limit)
#figure out how to distribute the bandwidth amongst the windows,
#we use the window size,
#(we should actually use the number of bytes actually sent: framerate, compression, etc..)
#(we should use the number of bytes actually sent: framerate, compression, etc..)
window_weight = {}
for wid, ws in self.window_sources.items():
weight = 0
Expand Down Expand Up @@ -263,9 +266,10 @@ def parse_hello(self, c):
if self.server_bandwidth_limit is None:
server_bandwidth_limit = self.get_socket_bandwidth_limit() or bandwidth_limit
self.bandwidth_limit = min(server_bandwidth_limit, bandwidth_limit)
self.bandwidth_detection = c.boolget("bandwidth-detection", True)
cd = typedict(c.dictget("connection-data"))
self.jitter = cd.intget("jitter", 0)
bandwidthlog("server bandwidth-limit=%s, client bandwidth-limit=%s, value=%s", server_bandwidth_limit, bandwidth_limit, self.bandwidth_limit)
bandwidthlog("server bandwidth-limit=%s, client bandwidth-limit=%s, value=%s, detection=%s", server_bandwidth_limit, bandwidth_limit, self.bandwidth_limit, self.bandwidth_detection)

cinfo = self.get_connect_info()
for i,ci in enumerate(cinfo):
Expand Down Expand Up @@ -430,6 +434,7 @@ def get_info(self):
"jitter" : self.jitter,
"bandwidth-limit" : {
"setting" : self.bandwidth_limit or 0,
"detection" : self.bandwidth_detection,
"actual" : self.soft_bandwidth_limit or 0,
}
}
Expand Down

0 comments on commit 4f210c9

Please sign in to comment.