aboutsummaryrefslogtreecommitdiff
path: root/rpkid
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2011-10-04 18:06:44 +0000
committerRob Austein <sra@hactrn.net>2011-10-04 18:06:44 +0000
commit83524080bba998ea1cbe3b7ae25d0b798f0b9ace (patch)
tree075cee18ce029c65069bf2c83fd1ea9677e609cb /rpkid
parent611653c06120d21dc326e7d97d51b45ddebbf297 (diff)
Rework http_queue exception handling not to drop the event chain if
callback handler throws an exception, eg, due to CMS validation failure. This closes #94. svn path=/rpkid/rpki/http.py; revision=4009
Diffstat (limited to 'rpkid')
-rw-r--r--rpkid/rpki/http.py29
-rw-r--r--rpkid/rpki/irdbd.py4
2 files changed, 22 insertions, 11 deletions
diff --git a/rpkid/rpki/http.py b/rpkid/rpki/http.py
index 7513cc3f..1638449a 100644
--- a/rpkid/rpki/http.py
+++ b/rpkid/rpki/http.py
@@ -908,19 +908,30 @@ class http_queue(object):
self.log("No caller. THIS SHOULD NOT HAPPEN. Dropping result %r" % result, rpki.log.warn)
return
- try:
- if isinstance(result, http_response):
+ assert isinstance(result, http_response) or isinstance(result, Exception)
+
+ if isinstance(result, http_response):
+ try:
self.log("Returning result %r to caller" % result)
req.callback(result.body)
- else:
- assert isinstance(result, Exception)
+ except (rpki.async.ExitNow, SystemExit):
+ raise
+ except Exception, e:
+ result = e
+
+ if isinstance(result, Exception):
+ try:
self.log("Returning exception %r to caller: %s" % (result, result), rpki.log.warn)
req.errback(result)
- except (rpki.async.ExitNow, SystemExit):
- raise
- except:
- self.log("Unhandled exception from callback")
- rpki.log.traceback()
+ except (rpki.async.ExitNow, SystemExit):
+ raise
+ except:
+ #
+ # If we get here, we may have lost the event chain. Not
+ # obvious what we can do about it at this point.
+ #
+ self.log("Exception in exception callback", rpki.log.warn)
+ rpki.log.traceback()
self.log("Queue: %r" % self.queue)
diff --git a/rpkid/rpki/irdbd.py b/rpkid/rpki/irdbd.py
index d092d810..a8a17649 100644
--- a/rpkid/rpki/irdbd.py
+++ b/rpkid/rpki/irdbd.py
@@ -167,14 +167,14 @@ class main(object):
raise
except Exception, data:
- rpki.log.traceback()
+ #rpki.log.traceback()
r_msg.append(rpki.left_right.report_error_elt.from_exception(data, q_pdu.self_handle, q_pdu.tag))
except (rpki.async.ExitNow, SystemExit):
raise
except Exception, data:
- rpki.log.traceback()
+ #rpki.log.traceback()
r_msg.append(rpki.left_right.report_error_elt.from_exception(data))
cb(200, body = rpki.left_right.cms_msg().wrap(r_msg, self.irdbd_key, self.irdbd_cert))