From 6bf591ee14b4efef39e5681f6763b57919624265 Mon Sep 17 00:00:00 2001 From: Michael Barton Date: Sun, 17 Oct 2010 01:20:22 +0000 Subject: [PATCH] clarify code by separating accumulator into two counters --- swift/obj/replicator.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/swift/obj/replicator.py b/swift/obj/replicator.py index bb0ac20852..47d032561c 100644 --- a/swift/obj/replicator.py +++ b/swift/obj/replicator.py @@ -363,22 +363,23 @@ class ObjectReplicator(Daemon): do_listdir=(self.replication_count % 10) == 0, reclaim_age=self.reclaim_age) self.suffix_hash += hashed - not_unmounted = 0 + unmounted = 0 + attempted = 0 nodes = itertools.chain(job['nodes'], self.object_ring.get_more_nodes(int(job['partition']))) - while not_unmounted < (self.object_ring.replica_count - 1): + while (attempted - unmounted) < (self.object_ring.replica_count - 1): node = next(nodes) - not_unmounted += 1 + attempted += 1 try: with Timeout(60): resp = http_connect(node['ip'], node['port'], node['device'], job['partition'], 'REPLICATE', '', headers={'Content-Length': '0'}).getresponse() - if resp.status == 507: - not_unmounted -= 1 if resp.status != 200: self.logger.error("Invalid response %s from %s" % (resp.status, node['ip'])) + if resp.status == 507: + unmounted += 1 continue remote_hash = pickle.loads(resp.read()) del resp