From 8620c7271d6a51442f9cf71ab73aae2515d0a5ae Mon Sep 17 00:00:00 2001
From: robk-tahoe <robk-tahoe@allmydata.com>
Date: Thu, 10 Apr 2008 14:27:35 -0700
Subject: [PATCH] key_generator: fix edge case found on windows

the windows (cygwin) buildslave has been failing the key generator test

it turns out that the time check on whether to refill the pool, and the
reactor, are interacting such that when the maybe_refill_pool call posted
on the reactor fires, the test on whether to fill the pool fails.

this adds a loop in the failure case to retry each 1s until it is time
to refill the pool, thus mitigating this timing accuracy problem on
windows.
---
 src/allmydata/key_generator.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/allmydata/key_generator.py b/src/allmydata/key_generator.py
index 61fa9b2e..fd9b096f 100644
--- a/src/allmydata/key_generator.py
+++ b/src/allmydata/key_generator.py
@@ -55,6 +55,7 @@ class KeyGenerator(service.MultiService, foolscap.Referenceable):
                 self.keypool.append(self.gen_key(self.DEFAULT_KEY_SIZE))
         else:
             self.vlog('%s not refilling pool' % (self,))
+            reactor.callLater(1, self.maybe_refill_pool)
 
     def gen_key(self, key_size):
         self.vlog('%s generating key size %s' % (self, key_size, ))
-- 
2.45.2