From: Brian Warner <warner@lothar.com>
Date: Sat, 2 Jan 2010 22:08:41 +0000 (-0800)
Subject: mutable/publish: don't loop() right away upon DeadReferenceError. Closes #877
X-Git-Tag: trac-4200~51
X-Git-Url: https://git.rkrishnan.org/simplejson/components/frontends//%22%22.?a=commitdiff_plain;h=419a076f59b93e66ff799244a6c0a85e9070e21d;p=tahoe-lafs%2Ftahoe-lafs.git

mutable/publish: don't loop() right away upon DeadReferenceError. Closes #877

The bug was that a disconnected server could cause us to re-enter the initial
loop() call, sending multiple queries to a single server, provoking an
incorrect UCWE. To fix it, stall the loop() with an eventual.fireEventually()
---

diff --git a/src/allmydata/mutable/publish.py b/src/allmydata/mutable/publish.py
index e9b68cd7..39ed649b 100644
--- a/src/allmydata/mutable/publish.py
+++ b/src/allmydata/mutable/publish.py
@@ -10,7 +10,7 @@ from allmydata.util import base32, hashutil, mathutil, idlib, log
 from allmydata import hashtree, codec
 from allmydata.storage.server import si_b2a
 from pycryptopp.cipher.aes import AES
-from foolscap.api import eventually
+from foolscap.api import eventually, fireEventually
 
 from common import MODE_WRITE, MODE_CHECK, DictOfSets, \
      UncoordinatedWriteError, NotEnoughServersError
@@ -636,6 +636,8 @@ class Publish:
             d.addCallbacks(self._got_write_answer, self._got_write_error,
                            callbackArgs=(peerid, shnums, started),
                            errbackArgs=(peerid, shnums, started))
+            # tolerate immediate errback, like with DeadReferenceError
+            d.addBoth(fireEventually)
             d.addCallback(self.loop)
             d.addErrback(self._fatal_error)