diff --git a/src/xpra/server/server_core.py b/src/xpra/server/server_core.py index b20bbbbf55..32ad9ed314 100644 --- a/src/xpra/server/server_core.py +++ b/src/xpra/server/server_core.py @@ -685,30 +685,31 @@ def start_websockify(self, conn, frominfo): from xpra.net.websocket import WebSocketConnection, WSRequestHandler try: sock = conn._socket - #set the websocket to non-blocking because: - # * win32 servers don't seem to honour our request to use blocking sockets anyway - # (this should not be needed on any other platform, - # maybe this should go in websockify somewhere instead) - # * the proxy server needs this to steal the connection + # win32 servers don't seem to honour our request to use blocking sockets + # (this workaround should not be needed on any other platform, + # and maybe this should go in websockify somewhere instead) from xpra.net.bytestreams import untilConcludes - saved_recv = sock.recv - saved_send = sock.send - def recv(*args): - return untilConcludes(conn.is_active, saved_recv, *args) - def send(*args): - return untilConcludes(conn.is_active, saved_send, *args) - sock.recv = recv - sock.send = send - def new_websocket_client(wsh): - netlog("new_websocket_client(%s) socket=%s", wsh, sock) - wsc = WebSocketConnection(sock, conn.local, conn.remote, conn.target, conn.socktype, wsh) - #now we can have a "is_active" that belongs to the real connection object: + WIN32 = sys.platform.startswith("win") + if WIN32: + saved_recv = sock.recv + saved_send = sock.send def recv(*args): - return untilConcludes(wsc.is_active, saved_recv, *args) + return untilConcludes(conn.is_active, saved_recv, *args) def send(*args): - return untilConcludes(wsc.is_active, saved_send, *args) + return untilConcludes(conn.is_active, saved_send, *args) sock.recv = recv sock.send = send + def new_websocket_client(wsh): + netlog("new_websocket_client(%s) socket=%s", wsh, sock) + wsc = WebSocketConnection(sock, conn.local, conn.remote, conn.target, conn.socktype, wsh) + if WIN32: + #now we can have a "is_active" that belongs to the real connection object: + def recv(*args): + return untilConcludes(wsc.is_active, saved_recv, *args) + def send(*args): + return untilConcludes(wsc.is_active, saved_send, *args) + sock.recv = recv + sock.send = send self.make_protocol("tcp", wsc, frominfo) WSRequestHandler(sock, frominfo, new_websocket_client, self._www_dir) return