aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2009-05-17 14:59:36 +0000
committerRob Austein <sra@hactrn.net>2009-05-17 14:59:36 +0000
commit9a7e24ee54b84665edf3f23e87f864bfcc88d1dd (patch)
tree11c6b6a5c45fdbf291d0075643e300381b61a545
parentf461f6f343e9ef895966d883d87dbdc1241dcf7d (diff)
Defer connection attempts until after allowing I/O to run, in case
we've been running compute bound (or otherwise not handling I/O) for long enough that we have connection close events queued up. svn path=/rpkid/rpki/https.py; revision=2438
-rw-r--r--rpkid/rpki/https.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/rpkid/rpki/https.py b/rpkid/rpki/https.py
index e4dcb7c1..838e5b88 100644
--- a/rpkid/rpki/https.py
+++ b/rpkid/rpki/https.py
@@ -482,7 +482,6 @@ class http_queue(object):
def request(self, *requests):
self.log("Adding requests %r" % requests)
self.queue.extend(requests)
- self.restart()
def restart(self):
if self.client is None:
@@ -534,7 +533,8 @@ queues = {}
def client(msg, client_key, client_cert, server_ta, url, callback, errback):
"""
- Open client HTTPS connection, send a message, wait for response.
+ Open client HTTPS connection, send a message, set up callbacks to
+ handle response.
THIS VERSION DOES NOT DO TLS. THIS IS EXPERIMENTAL CODE. DO NOT
USE IN PRODUCTION UNTIL TLS SUPPORT HAS BEEN ADDED.
@@ -568,6 +568,12 @@ def client(msg, client_key, client_cert, server_ta, url, callback, errback):
queues[hostport] = http_queue(hostport)
queues[hostport].request(request)
+ # Defer connection attempt until after we've had time to process any
+ # pending I/O events, in case connections have closed.
+
+ rpki.log.debug("Scheduling connection startup for %r" % request)
+ rpki.async.timer(queues[hostport].restart, errback).set(None)
+
def server(handlers, server_key, server_cert, port, host ="", client_ta = None, dynamic_https_trust_anchor = None):
"""
Run an HTTPS server and wait (forever) for connections.