close protocol if transport reuse brings responses before requests

This commit is contained in:
Victor Shyba 2019-05-02 12:13:33 -03:00
parent ac69fcbc5f
commit ff2985cc80

View file

@ -35,6 +35,9 @@ class BlobExchangeClientProtocol(asyncio.Protocol):
if self._response_fut and not self._response_fut.done():
self._response_fut.cancel()
return
if not self._response_fut:
log.warning("Protocol received data before expected, probable race on keep alive. Closing transport.")
return self.close()
if self._blob_bytes_received and not self.writer.closed():
return self._write(data)