From: Brian Warner Date: Thu, 8 Nov 2007 00:45:45 +0000 (-0700) Subject: mutable: make error handling more robust X-Git-Tag: allmydata-tahoe-0.7.0~251 X-Git-Url: https://git.rkrishnan.org/frontends//%22%22?a=commitdiff_plain;h=30e7ca06f5de455a2faf774042d6ab41956ebe6d;p=tahoe-lafs%2Ftahoe-lafs.git mutable: make error handling more robust --- diff --git a/src/allmydata/mutable.py b/src/allmydata/mutable.py index dd063252..909049bb 100644 --- a/src/allmydata/mutable.py +++ b/src/allmydata/mutable.py @@ -3,7 +3,7 @@ import os, struct from itertools import islice from zope.interface import implements from twisted.internet import defer -from twisted.python import failure +from twisted.python import failure, log from foolscap.eventual import eventually from allmydata.interfaces import IMutableFileNode, IMutableFileURI from allmydata.util import hashutil, mathutil, idlib @@ -172,6 +172,9 @@ class Retrieve: #self._node._client.log(msg) pass + def log_err(self, f): + log.err(f) + def retrieve(self): """Retrieve the filenode's current contents. Returns a Deferred that fires with a string when the contents have been retrieved.""" @@ -303,6 +306,10 @@ class Retrieve: d.addCallback(self._got_results, peerid, readsize) d.addErrback(self._query_failed, peerid, (conn, storage_index, peer_storage_servers)) + # errors that aren't handled by _query_failed (and errors caused by + # _query_failed) get logged, but we still want to check for doneness. + d.addErrback(log.err) + d.addBoth(self._check_for_done) return d def _deserialize_pubkey(self, pubkey_s): @@ -358,8 +365,6 @@ class Retrieve: _ignored = unpack_share(data) self._valid_versions[verinfo][1].add(shnum, (peerid, data)) - self._check_for_done() - def _query_failed(self, f, peerid, stuff): self._queries_outstanding.discard(peerid) @@ -380,9 +385,10 @@ class Retrieve: self.log("WEIRD: bad share for %s: %s" % (short_sid, f)) else: self.log("WEIRD: other error for %s: %s" % (short_sid, f)) - self._check_for_done() - def _check_for_done(self): + def _check_for_done(self, res): + if not self._running: + return share_prefixes = {} versionmap = DictOfSets() for verinfo, (prefix, sharemap) in self._valid_versions.items():