Commit ce7cc527 authored by Alexander Schrode's avatar Alexander Schrode Committed by oroulet

Always close secure channel

parent 85ff8559
...@@ -209,8 +209,10 @@ class Client: ...@@ -209,8 +209,10 @@ class Client:
try: try:
await self.send_hello() await self.send_hello()
await self.open_secure_channel() await self.open_secure_channel()
endpoints = await self.get_endpoints() try:
await self.close_secure_channel() endpoints = await self.get_endpoints()
finally:
await self.close_secure_channel()
finally: finally:
self.disconnect_socket() self.disconnect_socket()
return endpoints return endpoints
...@@ -223,8 +225,10 @@ class Client: ...@@ -223,8 +225,10 @@ class Client:
try: try:
await self.send_hello() await self.send_hello()
await self.open_secure_channel() # spec says it should not be necessary to open channel await self.open_secure_channel() # spec says it should not be necessary to open channel
servers = await self.find_servers() try:
await self.close_secure_channel() servers = await self.find_servers()
finally:
await self.close_secure_channel()
finally: finally:
self.disconnect_socket() self.disconnect_socket()
return servers return servers
...@@ -237,8 +241,10 @@ class Client: ...@@ -237,8 +241,10 @@ class Client:
try: try:
await self.send_hello() await self.send_hello()
await self.open_secure_channel() await self.open_secure_channel()
servers = await self.find_servers_on_network() try:
await self.close_secure_channel() servers = await self.find_servers_on_network()
finally:
await self.close_secure_channel()
finally: finally:
self.disconnect_socket() self.disconnect_socket()
return servers return servers
...@@ -253,7 +259,12 @@ class Client: ...@@ -253,7 +259,12 @@ class Client:
try: try:
await self.send_hello() await self.send_hello()
await self.open_secure_channel() await self.open_secure_channel()
await self.create_session() try:
await self.create_session()
except Exception:
# clean up secure channel
self.close_secure_channel()
raise
except Exception: except Exception:
# clean up open socket # clean up open socket
self.disconnect_socket() self.disconnect_socket()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment