Skip to content

Commit e5927d2

Browse files
Avoid infinite recursion when exiting a service connected to LS
Finalize had a logging call between the termination of the socket and the marking of the client as disconnected; therefore the logging module attempted to send the log to LS, but this incurred in an error as the socket was close. The new error was then logged again, causing the infinte recursion. With the logging call after the client has been marked as disconnected, execute_rpc for the log call returns early without errors.
1 parent 3d48dff commit e5927d2

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

cms/io/rpc.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Contest Management System - http://cms-dev.github.io/
55
# Copyright © 2010-2013 Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
6-
# Copyright © 2010-2015 Stefano Maggiolo <s.maggiolo@gmail.com>
6+
# Copyright © 2010-2018 Stefano Maggiolo <s.maggiolo@gmail.com>
77
# Copyright © 2010-2012 Matteo Boscariol <boscarim@hotmail.com>
88
# Copyright © 2013-2017 Luca Wehrstedt <luca.wehrstedt@gmail.com>
99
#
@@ -185,15 +185,17 @@ def finalize(self, reason=""):
185185
if not self.connected:
186186
return
187187

188-
logger.info("Terminated connection with %s (local address: %s): %s",
189-
self._repr_remote(), self._local_address, reason)
188+
local_address = self._local_address
190189

191190
self._socket = None
192191
self._reader = None
193192
self._writer = None
194193
self._local_address = None
195194
self._connection_event.clear()
196195

196+
logger.info("Terminated connection with %s (local address: %s): %s",
197+
self._repr_remote(), local_address, reason)
198+
197199
for handler in self._on_disconnect_handlers:
198200
gevent.spawn(handler)
199201

0 commit comments

Comments
 (0)