Skip to content

Commit

Permalink
shutdown bad socket (after signal)
Browse files Browse the repository at this point in the history
  • Loading branch information
jczic committed Feb 11, 2024
1 parent 0ec3f3f commit 393891f
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions MicroWebSrv2/libs/XAsyncSockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,28 +107,31 @@ def _processWaitEvents(self) :
XAsyncSocketsPool._CHECK_SEC_INTERVAL )
except KeyboardInterrupt as ex :
raise ex
except :
except Exception as ex :
continue
if not self._processing :
break
for socketsList in ex, wr, rd :
for socket in socketsList :
for sock in socketsList :
with self._opLock :
asyncSocket = self._asyncSockets.get(socket.fileno(), None)
asyncSocket = self._asyncSockets.get(sock.fileno(), None)
if asyncSocket :
if self._socketListAdd(socket, self._handlingList) :
if self._socketListAdd(sock, self._handlingList) :
if socketsList is ex :
asyncSocket.OnExceptionalCondition()
self._socketListRemove(sock, self._readList)
self._socketListRemove(sock, self._writeList)
sock.shutdown(socket.SHUT_RDWR)
elif socketsList is wr :
self._socketListRemove(socket, self._writeList)
self._socketListRemove(sock, self._writeList)
asyncSocket.OnReadyForWriting()
else :
asyncSocket.OnReadyForReading()
self._socketListRemove(socket, self._handlingList)
self._socketListRemove(sock, self._handlingList)
else :
self._socketListRemove(socket, self._readList)
self._socketListRemove(socket, self._writeList)
socket.close()
self._socketListRemove(sock, self._readList)
self._socketListRemove(sock, self._writeList)
sock.shutdown(socket.SHUT_RDWR)
sec = perf_counter()
if sec > timeSec + XAsyncSocketsPool._CHECK_SEC_INTERVAL :
timeSec = sec
Expand All @@ -138,6 +141,8 @@ def _processWaitEvents(self) :
asyncSocket._close(XClosedReason.Timeout)
except KeyboardInterrupt :
self._processing = False
except :
pass
self._decThreadsCount()

# ------------------------------------------------------------------------
Expand Down

0 comments on commit 393891f

Please sign in to comment.