From: Daira Hopwood Date: Fri, 10 May 2013 21:21:23 +0000 (+0100) Subject: mutable/retrieve.py: inline the single-use function _remove_reader. X-Git-Tag: allmydata-tahoe-1.10.1a1~246 X-Git-Url: https://git.rkrishnan.org/pf/content/en/%3C?a=commitdiff_plain;h=a74b09ec866ef547960c9fcc65f5908d351bf5cb;p=tahoe-lafs%2Ftahoe-lafs.git mutable/retrieve.py: inline the single-use function _remove_reader. A simple refactoring. Doesn't even require a new or updated unit test. Author: Zooko O'Whielacronx Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/mutable/retrieve.py b/src/allmydata/mutable/retrieve.py index b92e931f..26d1747b 100644 --- a/src/allmydata/mutable/retrieve.py +++ b/src/allmydata/mutable/retrieve.py @@ -527,40 +527,6 @@ class Retrieve: "indicate an uncoordinated write") # Otherwise, we're okay -- no issues. - - def _remove_reader(self, reader): - """ - At various points, we will wish to remove a server from - consideration and/or use. These include, but are not necessarily - limited to: - - - A connection error. - - A mismatched prefix (that is, a prefix that does not match - our conception of the version information string). - - A failing block hash, salt hash, or share hash, which can - indicate disk failure/bit flips, or network trouble. - - This method will do that. I will make sure that the - (shnum,reader) combination represented by my reader argument is - not used for anything else during this download. I will not - advise the reader of any corruption, something that my callers - may wish to do on their own. - """ - # TODO: When you're done writing this, see if this is ever - # actually used for something that _mark_bad_share isn't. I have - # a feeling that they will be used for very similar things, and - # that having them both here is just going to be an epic amount - # of code duplication. - # - # (well, okay, not epic, but meaningful) - self.log("removing reader %s" % reader) - # Remove the reader from _active_readers - self._active_readers.remove(reader) - # TODO: self.readers.remove(reader)? - for shnum in list(self.remaining_sharemap.keys()): - self.remaining_sharemap.discard(shnum, reader.server) - - def _mark_bad_share(self, server, shnum, reader, f): """ I mark the given (server, shnum) as a bad share, which means that it @@ -585,14 +551,18 @@ class Retrieve: (shnum, server.get_name())) prefix = self.verinfo[-2] self.servermap.mark_bad_share(server, shnum, prefix) - self._remove_reader(reader) self._bad_shares.add((server, shnum, f)) self._status.add_problem(server, f) self._last_failure = f + + # Remove the reader from _active_readers + self._active_readers.remove(reader) + for shnum in list(self.remaining_sharemap.keys()): + self.remaining_sharemap.discard(shnum, reader.server) + if f.check(BadShareError): self.notify_server_corruption(server, shnum, str(f.value)) - def _download_current_segment(self): """ I download, validate, decode, decrypt, and assemble the segment