forked from LBRYCommunity/lbry-sdk
fix redundant blob request to peer
This commit is contained in:
parent
ab3c987034
commit
ffbcd82263
2 changed files with 4 additions and 19 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue