Skip to content

Commit

Permalink
fix infinite recursion when destroying sockets
Browse files Browse the repository at this point in the history
By having a `getattr` implementation that proxies to the `socket`
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`.
  • Loading branch information
tilgovi committed Mar 13, 2016
1 parent e05941c commit dca088d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gunicorn/sock.py
Expand Up @@ -53,11 +53,15 @@ def bind(self, sock):
sock.bind(self.cfg_addr)

def close(self):
if self.sock is None:
return

try:
self.sock.close()
except socket.error as e:
self.log.info("Error while closing socket %s", str(e))
del self.sock

self.sock = None


class TCPSocket(BaseSocket):
Expand Down

0 comments on commit dca088d

Please sign in to comment.