Skip to content

Commit

Permalink
#1298 / #1211: only use the untilConcludes workaround on win32
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@13865 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Sep 25, 2016
1 parent 398c3f5 commit bb1944e
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/xpra/server/server_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bb1944e

Please sign in to comment.