Skip to content

Commit

Permalink
Revert "Rely on close() to close sockets and stop using shutdown()"
Browse files Browse the repository at this point in the history
This reverts commit 64e4f18
because it broke the CI tests.
  • Loading branch information
arp102 committed Jul 26, 2024
1 parent feec443 commit 9d5b287
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion kmip/services/kmip_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,10 @@ def __del__(self):
self.close()

def close(self):
# Close the socket.
# Shutdown and close the socket.
if self.socket:
try:
self.socket.shutdown(socket.SHUT_RDWR)
self.socket.close()
except (OSError, socket.error):
# Can be thrown if the socket is not actually connected to
Expand Down
3 changes: 2 additions & 1 deletion kmip/services/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,12 @@ def stop(self):

self._logger.info("Shutting down server socket handler.")
try:
self._socket.shutdown(socket.SHUT_RDWR)
self._socket.close()
except Exception as e:
self._logger.exception(e)
raise exceptions.NetworkingError(
"Server failed to close socket handler."
"Server failed to shutdown socket handler."
)

if hasattr(self, "policy_monitor"):
Expand Down
1 change: 1 addition & 0 deletions kmip/services/server/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def run(self):
self._logger.info("Failure handling message loop")
self._logger.exception(e)

self._connection.shutdown(socket.SHUT_RDWR)
self._connection.close()
self._logger.info("Stopping session: {0}".format(self.name))

Expand Down

0 comments on commit 9d5b287

Please sign in to comment.