diff options
author | Rob Austein <sra@hactrn.net> | 2015-11-12 08:32:01 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2015-11-12 08:32:01 +0000 |
commit | 61a3d8a132af9906e85214d1f29e8552dd1b9e8e (patch) | |
tree | a3e025f4f333ba105de8dd8f9c3c3c29f085f547 /rpki/rpkid.py | |
parent | dd55d982548d76837e4a68331b2da3d973606f59 (diff) |
Add .__repr__() methods to rpkidb models. Rewrite
.publish_world_now() to something a little less whacky. Consolidate
fix for singleton URIs in SIA fields.
svn path=/branches/tk705/; revision=6170
Diffstat (limited to 'rpki/rpkid.py')
-rw-r--r-- | rpki/rpkid.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/rpki/rpkid.py b/rpki/rpkid.py index ceac39f4..b589705f 100644 --- a/rpki/rpkid.py +++ b/rpki/rpkid.py @@ -659,7 +659,12 @@ class publication_queue(object): collection and do repository.call_pubd() for each repository. """ - replace = True + # At present, ._inplay and .inplay() are debugging tools only. If + # there turns out to be a real race condition here, this might + # evolve into the hook for some kind of Condition()-based + # mechanism. + + _inplay = weakref.WeakValueDictionary() def __init__(self, rpkid): self.rpkid = rpkid @@ -669,8 +674,11 @@ class publication_queue(object): self.repositories = {} self.msgs = {} self.handlers = {} - if self.replace: - self.uris = {} + self.uris = {} + + def inplay(self, uri): + who = self._inplay.get(uri, self) + return who is not self and uri in who.uris def queue(self, uri, repository, handler = None, old_obj = None, new_obj = None, old_hash = None): @@ -683,14 +691,17 @@ class publication_queue(object): logger.debug("Queuing publication action: uri %s, old %r, new %r, hash %s", uri, old_obj, new_obj, old_hash) + if self.inplay(uri): + logger.warning("%s is already in play", uri) + rid = repository.peer_contact_uri if rid not in self.repositories: self.repositories[rid] = repository self.msgs[rid] = Element(rpki.publication.tag_msg, nsmap = rpki.publication.nsmap, type = "query", version = rpki.publication.version) - if self.replace and uri in self.uris: - logger.debug("Removing publication duplicate %r hash %s", self.uris[uri], self.uris[uri].get("hash")) + if uri in self.uris: + logger.debug("Removing publication duplicate %r %s hash %s", self.uris[uri], uri, self.uris[uri].get("hash")) old_pdu = self.uris.pop(uri) self.msgs[rid].remove(old_pdu) pdu_hash = old_pdu.get("hash") @@ -721,14 +732,17 @@ class publication_queue(object): if handler is not None: self.handlers[uri] = handler - if self.replace: - self.uris[uri] = pdu + self.uris[uri] = pdu + self._inplay[uri] = self @tornado.gen.coroutine def call_pubd(self): for rid in self.repositories: logger.debug("Calling pubd[%r]", self.repositories[rid]) yield self.repositories[rid].call_pubd(self.rpkid, self.msgs[rid], self.handlers) + for k in self.uris.iterkeys(): + if self._inplay.get(k) is self: + del self._inplay[k] self.clear() @property |