Skip to content

Commit

Permalink
When closing the socket, set it to None
Browse files Browse the repository at this point in the history
This avoids calling close() twice on the same socket if self.close() or
self.handle_close() is called multiple times
  • Loading branch information
digitalresistor committed Mar 3, 2024
1 parent 63678e6 commit 9d99c89
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/waitress/wasyncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ def close(self):
if why.args[0] not in (ENOTCONN, EBADF):
raise

self.socket = None

# log and log_info may be overridden to provide more sophisticated
# logging and warning methods. In general, log is for 'hit' logging
# and 'log_info' is for informational, warning and error logging.
Expand Down Expand Up @@ -486,7 +488,11 @@ def handle_expt_event(self):
# handle_expt_event() is called if there might be an error on the
# socket, or if there is OOB data
# check for the error condition first
err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
err = (
self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
if self.socket is not None
else 1
)
if err != 0:
# we can get here when select.select() says that there is an
# exceptional condition on the socket
Expand Down

0 comments on commit 9d99c89

Please sign in to comment.