mirror of
https://github.com/openkmip/pykmip
synced 2025-12-05 23:53:19 +00:00
Fixing bug terminating connection prematurely
This change fixes a bug with the KmipSession connection handling logic that would terminate the connection before actually receiving a termination from the client. The corresponding unit tests have been updated to reflect this fix.
This commit is contained in:
@@ -70,15 +70,18 @@ class KmipSession(threading.Thread):
|
||||
"""
|
||||
self._logger.info("Starting session: {0}".format(self.name))
|
||||
|
||||
try:
|
||||
self._handle_message_loop()
|
||||
except Exception as e:
|
||||
self._logger.info("Failure handling message loop")
|
||||
self._logger.exception(e)
|
||||
finally:
|
||||
self._connection.shutdown(socket.SHUT_RDWR)
|
||||
self._connection.close()
|
||||
self._logger.info("Stopping session: {0}".format(self.name))
|
||||
while True:
|
||||
try:
|
||||
self._handle_message_loop()
|
||||
except exceptions.ConnectionClosed as e:
|
||||
break
|
||||
except Exception as e:
|
||||
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))
|
||||
|
||||
def _handle_message_loop(self):
|
||||
request_data = self._receive_request()
|
||||
@@ -164,6 +167,8 @@ class KmipSession(threading.Thread):
|
||||
|
||||
if partial_message is None:
|
||||
break
|
||||
elif len(partial_message) == 0:
|
||||
raise exceptions.ConnectionClosed()
|
||||
else:
|
||||
bytes_received += len(partial_message)
|
||||
message += partial_message
|
||||
|
||||
Reference in New Issue
Block a user