Fix Socket

This commit is contained in:
Florian Mounier
2015-05-25 10:33:24 +02:00
parent 81c61ec466
commit 6e5edde6dc
2 changed files with 9 additions and 6 deletions

View File

@@ -97,7 +97,7 @@ class Font(Route):
'(?:session/(?P<session>[^/]+))?/?'
'(?:/wd/(?P<path>.+))?')
class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
session_history_size = 100000
session_history_size = 10000
# List of websockets per session
sessions = {}
@@ -203,8 +203,11 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
TermWebSocket.sockets.remove(self)
if self.session:
TermWebSocket.sessions[self.session].remove(self)
else:
elif hasattr(self, '_terminal'):
self._terminal.close()
else:
self.log.error(
'Socket with neither session nor terminal %r' % self)
if self.application.systemd and not len(TermWebSocket.terminals):
sys.exit(0)

View File

@@ -73,13 +73,13 @@ class Terminal(object):
"Can't switch to user %s" % self.user, exc_info=True)
self.callee = None
# If no user where given and we are local, keep the same user
# as the one who opened the socket
# ie: the one openning a terminal in borwser
# If no user where given and we are local, keep the same
# user as the one who opened the socket ie: the one
# openning a terminal in browser
if not self.callee and not self.user and self.socket.local:
self.callee = self.caller
else:
user = utils.parse_cert(self.stream.socket.getpeercert())
user = utils.parse_cert(socket.getpeercert())
assert user, 'No user in certificate'
self.user = user
try: