mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-24 15:28:10 +00:00
python: ensure client session counter is never negative
This commit is contained in:
parent
3f9b0b7f4f
commit
598e828844
@ -132,9 +132,9 @@ class TrezorClient:
|
||||
self.session_counter += 1
|
||||
|
||||
def close(self):
|
||||
if self.session_counter == 1:
|
||||
self.session_counter = max(self.session_counter - 1, 0)
|
||||
if self.session_counter == 0:
|
||||
self.transport.end_session()
|
||||
self.session_counter -= 1
|
||||
|
||||
def cancel(self):
|
||||
self._raw_write(messages.Cancel())
|
||||
|
@ -93,9 +93,9 @@ class Protocol:
|
||||
self.session_counter += 1
|
||||
|
||||
def end_session(self) -> None:
|
||||
if self.session_counter == 1:
|
||||
self.session_counter = max(self.session_counter - 1, 0)
|
||||
if self.session_counter == 0:
|
||||
self.handle.close()
|
||||
self.session_counter -= 1
|
||||
|
||||
def read(self) -> protobuf.MessageType:
|
||||
raise NotImplementedError
|
||||
|
Loading…
Reference in New Issue
Block a user