Browse Source

fixed memory leak on rejected connections

Fixes https://github.com/miguelgrinberg/Flask-SocketIO/issues/574
pull/146/head
Miguel Grinberg 7 years ago
parent
commit
66e17fb387
No known key found for this signature in database GPG Key ID: 36848B262DF5F06C
  1. 2
      socketio/server.py
  2. 1
      tests/test_server.py
  3. 2
      tox.ini

2
socketio/server.py

@ -422,6 +422,8 @@ class Server(object):
self.manager.disconnect(sid, namespace)
self._send_packet(sid, packet.Packet(packet.ERROR,
namespace=namespace))
if sid in self.environ: # pragma: no cover
del self.environ[sid]
return False
else:
self._send_packet(sid, packet.Packet(packet.CONNECT,

1
tests/test_server.py

@ -204,6 +204,7 @@ class TestServer(unittest.TestCase):
handler.assert_called_once_with('123', 'environ')
self.assertEqual(s.manager.connect.call_count, 1)
self.assertEqual(s.manager.disconnect.call_count, 1)
self.assertEqual(s.environ, {})
s.eio.send.assert_called_once_with('123', '4', binary=False)
def test_handle_connect_namespace_rejected(self, eio):

2
tox.ini

@ -22,7 +22,7 @@ basepython=python3.6
deps=
flake8
commands=
flake8 --exclude=".*" --ignore=E402 socketio tests
flake8 --exclude=".*" --ignore=E402,E722 socketio tests
[testenv:docs]
basepython=python2.7

Loading…
Cancel
Save