Skip to content

Commit

Permalink
same as r17246 but for the server side: use 80% of the interface spee…
Browse files Browse the repository at this point in the history
…d as bandwidth-limit

git-svn-id: https://xpra.org/svn/Xpra/trunk@17247 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 24, 2017
1 parent 5cc23ba commit d000900
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
SAVE_PRINT_JOBS = os.environ.get("XPRA_SAVE_PRINT_JOBS", None)
CLIENT_CAN_SHUTDOWN = envbool("XPRA_CLIENT_CAN_SHUTDOWN", True)
TERMINATE_DELAY = envint("XPRA_TERMINATE_DELAY", 1000)/1000.0
AUTO_BANDWIDTH_PCT = envint("XPRA_AUTO_BANDWIDTH_PCT", 80)
assert AUTO_BANDWIDTH_PCT>1 and AUTO_BANDWIDTH_PCT<=100, "invalid value for XPRA_AUTO_BANDWIDTH_PCT: %i" % AUTO_BANDWIDTH_PCT


class ServerBase(ServerCore):
Expand Down Expand Up @@ -1196,6 +1198,15 @@ def drop_client(reason="unknown", *args):
self.disconnect_client(proto, reason, *args)
def get_window_id(wid):
return self._window_to_id.get(wid)
bandwidth_limit = self.bandwidth_limit
if bandwidth_limit is None:
pinfo = proto.get_info()
socket_speed = pinfo.get("socket", {}).get("speed")
if socket_speed:
#auto: use 80% of socket speed if we have it:
bandwidth_limit = socket_speed*AUTO_BANDWIDTH_PCT//100 or 0
else:
bandwidth_limit = 0
ServerSourceClass = self.get_server_source_class()
ss = ServerSourceClass(proto, drop_client,
self.idle_add, self.timeout_add, self.source_remove,
Expand All @@ -1206,7 +1217,7 @@ def get_window_id(wid):
self.window_filters,
self.file_transfer,
self.supports_mmap, self.mmap_filename,
self.bandwidth_limit,
bandwidth_limit,
self.av_sync,
self.core_encodings, self.encodings, self.default_encoding, self.scaling_control,
self.sound_properties,
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/server/server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def init(self, opts):
self.session_name = opts.session_name
set_name("Xpra", self.session_name or "Xpra")

self.bandwidth_limit = parse_with_unit("bandwidth-limit", opts.bandwidth_limit) or 0
self.bandwidth_limit = parse_with_unit("bandwidth-limit", opts.bandwidth_limit)
self.unix_socket_paths = []
self._socket_dir = opts.socket_dir or opts.socket_dirs[0]
self.encryption = opts.encryption
Expand Down Expand Up @@ -1555,7 +1555,7 @@ def up(prefix, d):
"sockets" : self.get_socket_info(),
"encryption" : self.encryption or "",
"tcp-encryption" : self.tcp_encryption or "",
"bandwidth-limit": self.bandwidth_limit,
"bandwidth-limit": self.bandwidth_limit or 0,
})
up("network", ni)
up("threads", self.get_thread_info(proto))
Expand Down

0 comments on commit d000900

Please sign in to comment.