From 419a076f59b93e66ff799244a6c0a85e9070e21d Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@lothar.com>
Date: Sat, 2 Jan 2010 14:08:41 -0800
Subject: [PATCH] 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()
---
 src/allmydata/mutable/publish.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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)
 
-- 
2.45.2