diff options
Diffstat (limited to 'rpkid/rpki')
-rw-r--r-- | rpkid/rpki/async.py | 12 | ||||
-rw-r--r-- | rpkid/rpki/https.py | 12 | ||||
-rw-r--r-- | rpkid/rpki/left_right.py | 6 | ||||
-rw-r--r-- | rpkid/rpki/publication.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/rpki_engine.py | 4 | ||||
-rw-r--r-- | rpkid/rpki/up_down.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/x509.py | 8 |
7 files changed, 37 insertions, 9 deletions
diff --git a/rpkid/rpki/async.py b/rpkid/rpki/async.py index c81bb474..cb2541b0 100644 --- a/rpkid/rpki/async.py +++ b/rpkid/rpki/async.py @@ -21,6 +21,8 @@ PERFORMANCE OF THIS SOFTWARE. import asyncore, signal, traceback import rpki.log, rpki.sundial +ExitNow = asyncore.ExitNow + class iterator(object): """Iteration construct for event-driven code. Takes three arguments: @@ -44,6 +46,8 @@ class iterator(object): self.done_callback = done_callback try: self.iterator = iter(iterable) + except ExitNow: + raise except: rpki.log.debug("Problem constructing iterator for %s" % repr(iterable)) raise @@ -146,7 +150,7 @@ class timer(object): t = cls.queue.pop(0) try: t.handler() - except asyncore.ExitNow: + except ExitNow: raise except Exception, e: t.errback(e) @@ -186,7 +190,7 @@ class timer(object): def _raiseExitNow(signum, frame): """Signal handler for event_loop().""" - raise asyncore.ExitNow + raise ExitNow def event_loop(catch_signals = (signal.SIGINT, signal.SIGTERM)): """Replacement for asyncore.loop(), adding timer and signal support.""" @@ -197,7 +201,7 @@ def event_loop(catch_signals = (signal.SIGINT, signal.SIGTERM)): while asyncore.socket_map or timer.queue: asyncore.poll(timer.seconds_until_wakeup(), asyncore.socket_map) timer.runq() - except asyncore.ExitNow: + except ExitNow: pass finally: for sig in old_signal_handlers: @@ -205,4 +209,4 @@ def event_loop(catch_signals = (signal.SIGINT, signal.SIGTERM)): def exit_event_loop(): """Force exit from event_loop().""" - raise asyncore.ExitNow + raise ExitNow diff --git a/rpkid/rpki/https.py b/rpkid/rpki/https.py index b3636118..47c5b81f 100644 --- a/rpkid/rpki/https.py +++ b/rpkid/rpki/https.py @@ -315,7 +315,7 @@ class http_server(http_stream): if error is None: try: handler(self.msg.body, self.msg.path, self.send_reply) - except asyncore.ExitNow: + except rpki.async.ExitNow: raise except Exception, edata: print traceback.format_exc() @@ -356,7 +356,7 @@ class http_listener(asyncore.dispatcher): self.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) self.bind((host, port)) self.listen(5) - except asyncore.ExitNow: + except rpki.async.ExitNow: raise except: self.handle_error() @@ -366,7 +366,7 @@ class http_listener(asyncore.dispatcher): self.log("Accepting connection") try: http_server(conn = self.accept()[0], handlers = self.handlers) - except asyncore.ExitNow: + except rpki.async.ExitNow: raise except: self.handle_error() @@ -391,6 +391,8 @@ class http_client(http_stream): try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.connect(self.hostport) + except rpki.async.ExitNow: + raise except: self.handle_error() @@ -461,6 +463,8 @@ class http_client(http_stream): self.queue.detach(self) try: raise + except rpki.async.ExitNow: + raise except Exception, edata: self.queue.return_result(edata) @@ -513,7 +517,7 @@ class http_queue(object): assert isinstance(result, Exception) self.log("Returning exception %r to caller: %s" % (result, result)) req.errback(result) - except asyncore.ExitNow: + except rpki.async.ExitNow: raise except: self.log("Unhandled exception from callback") diff --git a/rpkid/rpki/left_right.py b/rpkid/rpki/left_right.py index d355d2c1..fd590b11 100644 --- a/rpkid/rpki/left_right.py +++ b/rpkid/rpki/left_right.py @@ -542,6 +542,8 @@ class child_elt(data_elt): try: q_msg.serve_top_level(self, done) + except rpki.async.ExitNow: + raise except rpki.exceptions.NoActiveCA, data: done(q_msg.serve_error(data)) except Exception, data: @@ -583,6 +585,8 @@ class repository_elt(data_elt): if len(r_msg) != 1 or isinstance(r_msg[0], rpki.publication.report_error_elt): raise rpki.exceptions.BadPublicationReply, "Unexpected response from pubd: %s" % msg callback() + except rpki.async.ExitNow: + raise except Exception, edata: errback(edata) @@ -929,6 +933,8 @@ class msg(rpki.xml_utils.msg, left_right_namespace): try: q_pdu.gctx = gctx q_pdu.serve_dispatch(r_msg, iterator, fail) + except rpki.async.ExitNow: + raise except Exception, edata: fail(edata) diff --git a/rpkid/rpki/publication.py b/rpkid/rpki/publication.py index e9b525fd..b43fa60c 100644 --- a/rpkid/rpki/publication.py +++ b/rpkid/rpki/publication.py @@ -276,6 +276,8 @@ class msg(rpki.xml_utils.msg, publication_namespace): q_pdu.gctx = gctx q_pdu.client = client q_pdu.serve_dispatch(r_msg, iterator, fail) + except rpki.async.ExitNow: + raise except Exception, edata: fail(edata) diff --git a/rpkid/rpki/rpki_engine.py b/rpkid/rpki/rpki_engine.py index e983fa90..ed03ad29 100644 --- a/rpkid/rpki/rpki_engine.py +++ b/rpkid/rpki/rpki_engine.py @@ -89,6 +89,8 @@ class rpkid_context(object): if q_msg.type != "query": raise rpki.exceptions.BadQuery, "Message type is not query" q_msg.serve_top_level(self, done) + except rpki.async.ExitNow: + raise except Exception, data: rpki.log.error(traceback.format_exc()) cb(500, "Unhandled exception %s" % data) @@ -110,6 +112,8 @@ class rpkid_context(object): if child is None: raise rpki.exceptions.ChildNotFound, "Could not find child %s" % child_id child.serve_up_down(query, done) + except rpki.async.ExitNow: + raise except Exception, data: rpki.log.error(traceback.format_exc()) cb(400, "Could not process PDU: %s" % data) diff --git a/rpkid/rpki/up_down.py b/rpkid/rpki/up_down.py index 5b257a53..825a5d14 100644 --- a/rpkid/rpki/up_down.py +++ b/rpkid/rpki/up_down.py @@ -522,6 +522,8 @@ class message_pdu(base_elt): try: self.payload.serve_pdu(self, r_msg, child, done, lose) + except rpki.async.ExitNow: + raise except Exception, edata: lose(edata) diff --git a/rpkid/rpki/x509.py b/rpkid/rpki/x509.py index b167560c..9825e609 100644 --- a/rpkid/rpki/x509.py +++ b/rpkid/rpki/x509.py @@ -44,7 +44,7 @@ PERFORMANCE OF THIS SOFTWARE. import POW, tlslite.api, POW.pkix, base64, lxml.etree, os import rpki.exceptions, rpki.resource_set, rpki.oids, rpki.sundial -import rpki.manifest, rpki.roa, rpki.log +import rpki.manifest, rpki.roa, rpki.log, rpki.async def calculate_SKI(public_key_der): """Calculate the SKI value given the DER representation of a public @@ -672,6 +672,8 @@ class CMS_object(DER_object): try: cms = self.get_POW() + except rpki.async.ExitNow: + raise except: if self.print_on_der_error: rpki.log.debug("Problem parsing DER CMS message, might not really be DER: %s" @@ -724,6 +726,8 @@ class CMS_object(DER_object): try: content = cms.verify(store) + except rpki.async.ExitNow: + raise except: if self.dump_on_verify_failure: if True: @@ -750,6 +754,8 @@ class CMS_object(DER_object): try: cms = self.get_POW() + except rpki.async.ExitNow: + raise except: raise rpki.exceptions.UnparsableCMSDER |