From 64e4f18dd09de90335c663b07fc0933646355665 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Thu, 18 Aug 2022 17:39:27 -0700 Subject: [PATCH] Rely on close() to close sockets and stop using shutdown() --- kmip/services/kmip_client.py | 3 +-- kmip/services/server/server.py | 3 +-- kmip/services/server/session.py | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/kmip/services/kmip_client.py b/kmip/services/kmip_client.py index 7f72adf7..763ba386 100644 --- a/kmip/services/kmip_client.py +++ b/kmip/services/kmip_client.py @@ -301,10 +301,9 @@ def __del__(self): self.close() def close(self): - # Shutdown and close the socket. + # 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 diff --git a/kmip/services/server/server.py b/kmip/services/server/server.py index 534ab61d..d0f05f6e 100644 --- a/kmip/services/server/server.py +++ b/kmip/services/server/server.py @@ -362,12 +362,11 @@ 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 shutdown socket handler." + "Server failed to close socket handler." ) if hasattr(self, "policy_monitor"): diff --git a/kmip/services/server/session.py b/kmip/services/server/session.py index c6a5f70c..81a718eb 100644 --- a/kmip/services/server/session.py +++ b/kmip/services/server/session.py @@ -113,7 +113,6 @@ 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))