From ffbcd822638c99dfa8662042cc7b65c5fb87de12 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Fri, 15 Sep 2017 18:44:51 -0400 Subject: [PATCH] fix redundant blob request to peer --- lbrynet/core/client/BlobRequester.py | 3 ++- lbrynet/core/client/ClientProtocol.py | 20 ++------------------ 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/lbrynet/core/client/BlobRequester.py b/lbrynet/core/client/BlobRequester.py index 5e5aecf76..aa15c5961 100644 --- a/lbrynet/core/client/BlobRequester.py +++ b/lbrynet/core/client/BlobRequester.py @@ -226,7 +226,8 @@ class RequestHelper(object): self.requestor._update_local_score(self.peer, score) def _request_failed(self, reason, request_type): - if reason.check(DownloadCanceledError, RequestCanceledError, ConnectionAborted): + if reason.check(DownloadCanceledError, RequestCanceledError, ConnectionAborted, + ConnectionClosedBeforeResponseError): return if reason.check(NoResponseError): self.requestor._incompatible_peers.append(self.peer) diff --git a/lbrynet/core/client/ClientProtocol.py b/lbrynet/core/client/ClientProtocol.py index b6cf89f81..b8861a6ab 100644 --- a/lbrynet/core/client/ClientProtocol.py +++ b/lbrynet/core/client/ClientProtocol.py @@ -51,19 +51,8 @@ class ClientProtocol(Protocol, TimeoutMixin): self.setTimeout(None) self._rate_limiter.report_dl_bytes(len(data)) - def in_case_IOError(): - #TODO: writes can raise IOError if another peer finished - #writing and closes the other peeer's writers. Fix this - #by preventing peers from downloading the same blobs - msg = "Failed to write, blob is likely closed by another peer finishing download" - log.warn(msg) - self.transport.loseConnection() - if self._downloading_blob is True: - try: - self._blob_download_request.write(data) - except IOError as e: - in_case_IOError() + self._blob_download_request.write(data) else: self._response_buff += data if len(self._response_buff) > conf.settings['MAX_RESPONSE_INFO_SIZE']: @@ -75,12 +64,7 @@ class ClientProtocol(Protocol, TimeoutMixin): self._response_buff = '' self._handle_response(response) if self._downloading_blob is True and len(extra_data) != 0: - try: - self._blob_download_request.write(extra_data) - except IOError as e: - in_case_IOError() - - + self._blob_download_request.write(extra_data) def timeoutConnection(self): log.info("Connection timed out to %s", self.peer)