mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix infinite recursion when destroying sockets
By having a `getattr` implementation that proxies to the `sock` attribute, there is a risk of infinite recursion when the socket attribute is absent. After closing the socket and destroying it, the recursion can be prevented by setting the attribute to `None`.
This commit is contained in:
parent
e05941cec2
commit
e46dda7e76
@ -53,11 +53,15 @@ class BaseSocket(object):
|
|||||||
sock.bind(self.cfg_addr)
|
sock.bind(self.cfg_addr)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
if self.sock is None:
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
except socket.error as e:
|
except socket.error as e:
|
||||||
self.log.info("Error while closing socket %s", str(e))
|
self.log.info("Error while closing socket %s", str(e))
|
||||||
del self.sock
|
|
||||||
|
self.sock = None
|
||||||
|
|
||||||
|
|
||||||
class TCPSocket(BaseSocket):
|
class TCPSocket(BaseSocket):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user