wsproxy.py: python2.4 fixes.
This commit is contained in:
parent
c32e00c67f
commit
66937e399a
|
@ -23,7 +23,7 @@ except:
|
||||||
from urlparse import urlsplit
|
from urlparse import urlsplit
|
||||||
from cgi import parse_qsl
|
from cgi import parse_qsl
|
||||||
|
|
||||||
class WebSocketServer():
|
class WebSocketServer(object):
|
||||||
"""
|
"""
|
||||||
WebSockets server class.
|
WebSockets server class.
|
||||||
Must be sub-classed with new_client method definition.
|
Must be sub-classed with new_client method definition.
|
||||||
|
@ -345,49 +345,51 @@ Connection: Upgrade\r
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
csock = startsock = None
|
|
||||||
pid = err = 0
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.poll()
|
csock = startsock = None
|
||||||
|
pid = err = 0
|
||||||
|
|
||||||
ready = select.select([lsock], [], [], 1)[0];
|
try:
|
||||||
if lsock in ready:
|
self.poll()
|
||||||
startsock, address = lsock.accept()
|
|
||||||
|
ready = select.select([lsock], [], [], 1)[0];
|
||||||
|
if lsock in ready:
|
||||||
|
startsock, address = lsock.accept()
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
except Exception, exc:
|
||||||
|
if hasattr(exc, 'errno'):
|
||||||
|
err = exc.errno
|
||||||
|
else:
|
||||||
|
err = exc[0]
|
||||||
|
if err == errno.EINTR:
|
||||||
|
self.vmsg("Ignoring interrupted syscall")
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
self.vmsg('%s: forking handler' % address[0])
|
||||||
|
pid = os.fork()
|
||||||
|
|
||||||
|
if pid == 0:
|
||||||
|
# handler process
|
||||||
|
csock = self.do_handshake(startsock, address)
|
||||||
|
self.new_client(csock)
|
||||||
else:
|
else:
|
||||||
continue
|
# parent process
|
||||||
|
self.handler_id += 1
|
||||||
|
|
||||||
|
except self.EClose, exc:
|
||||||
|
# Connection was not a WebSockets connection
|
||||||
|
if exc.args[0]:
|
||||||
|
self.msg("%s: %s" % (address[0], exc.args[0]))
|
||||||
|
except KeyboardInterrupt, exc:
|
||||||
|
pass
|
||||||
except Exception, exc:
|
except Exception, exc:
|
||||||
if hasattr(exc, 'errno'):
|
self.msg("handler exception: %s" % str(exc))
|
||||||
err = exc.errno
|
if self.verbose:
|
||||||
elif type(exc) == select.error:
|
self.msg(traceback.format_exc())
|
||||||
err = exc[0]
|
|
||||||
if err == errno.EINTR:
|
|
||||||
self.vmsg("Ignoring interrupted syscall()")
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
|
|
||||||
self.vmsg('%s: forking handler' % address[0])
|
|
||||||
pid = os.fork()
|
|
||||||
|
|
||||||
if pid == 0:
|
|
||||||
# handler process
|
|
||||||
csock = self.do_handshake(startsock, address)
|
|
||||||
self.new_client(csock)
|
|
||||||
else:
|
|
||||||
# parent process
|
|
||||||
self.handler_id += 1
|
|
||||||
|
|
||||||
except self.EClose, exc:
|
|
||||||
# Connection was not a WebSockets connection
|
|
||||||
if exc.args[0]:
|
|
||||||
self.msg("%s: %s" % (address[0], exc.args[0]))
|
|
||||||
except KeyboardInterrupt, exc:
|
|
||||||
pass
|
|
||||||
except Exception, exc:
|
|
||||||
self.msg("handler exception: %s" % str(exc))
|
|
||||||
if self.verbose:
|
|
||||||
self.msg(traceback.format_exc())
|
|
||||||
finally:
|
finally:
|
||||||
if csock and csock != startsock:
|
if csock and csock != startsock:
|
||||||
csock.close()
|
csock.close()
|
||||||
|
|
Loading…
Reference in New Issue