Share: drop received data after each block finishes. Quick fix for the #1170 spans.py complexity bug.

This commit is contained in:
Brian Warner 2010-08-31 18:35:58 -07:00
parent b6c559e009
commit c89a464510
2 changed files with 5 additions and 2 deletions

View File

@ -531,6 +531,9 @@ class Share:
for o in observers: for o in observers:
# goes to SegmentFetcher._block_request_activity # goes to SegmentFetcher._block_request_activity
o.notify(state=COMPLETE, block=block) o.notify(state=COMPLETE, block=block)
# now clear our received data, to dodge the #1170 spans.py
# complexity bug
self._received = DataSpans()
except (BadHashError, NotEnoughHashesError), e: except (BadHashError, NotEnoughHashesError), e:
# rats, we have a corrupt block. Notify our clients that they # rats, we have a corrupt block. Notify our clients that they
# need to look elsewhere, and advise the server. Unlike # need to look elsewhere, and advise the server. Unlike

View File

@ -52,7 +52,7 @@ class Test(common.ShareManglingMixin, common.ShouldFailMixin, unittest.TestCase)
def _after_download(unused=None): def _after_download(unused=None):
after_download_reads = self._count_reads() after_download_reads = self._count_reads()
#print before_download_reads, after_download_reads #print before_download_reads, after_download_reads
self.failIf(after_download_reads-before_download_reads > 27, self.failIf(after_download_reads-before_download_reads > 36,
(after_download_reads, before_download_reads)) (after_download_reads, before_download_reads))
d.addCallback(self._download_and_check_plaintext) d.addCallback(self._download_and_check_plaintext)
d.addCallback(_after_download) d.addCallback(_after_download)
@ -70,7 +70,7 @@ class Test(common.ShareManglingMixin, common.ShouldFailMixin, unittest.TestCase)
def _after_download(unused=None): def _after_download(unused=None):
after_download_reads = self._count_reads() after_download_reads = self._count_reads()
#print before_download_reads, after_download_reads #print before_download_reads, after_download_reads
self.failIf(after_download_reads-before_download_reads > 27, (after_download_reads, before_download_reads)) self.failIf(after_download_reads-before_download_reads > 37, (after_download_reads, before_download_reads))
d.addCallback(self._download_and_check_plaintext) d.addCallback(self._download_and_check_plaintext)
d.addCallback(_after_download) d.addCallback(_after_download)
return d return d