api: fix handling interrupted calls

When an API call is interrupted, the relevant coroutine is cancelled -
which means it may throw CancelledError. At the same time, cancelled
call have related socket already closed (and transport set to None). But
QubesDaemonProtocol.respond try to close the transport again, which
fails. Fix handling this case.
This commit is contained in:
Marek Marczykowski-Górecki 2017-07-28 01:23:23 +02:00
parent 147bca1648
commit 2f4b4d97e7
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -307,7 +307,8 @@ class QubesDaemonProtocol(asyncio.Protocol):
# this is reached if from except: blocks; do not put it in finally:,
# because this will prevent the good case from sending the reply
self.transport.abort()
if self.transport:
self.transport.abort()
def send_header(self, *args):
self.transport.write(self.header.pack(*args))