diff --git a/include/ircd/server/node.h b/include/ircd/server/node.h index 803b3d4bb..85a0ff070 100644 --- a/include/ircd/server/node.h +++ b/include/ircd/server/node.h @@ -35,14 +35,14 @@ struct ircd::server::node void resolve(const hostport &); void disperse_uncommitted(link &); - void cancel_committed(link &, const std::exception &); + void cancel_committed(link &, std::exception_ptr); void disperse(link &); void del(link &); void handle_link_done(link &); void handle_tag_done(link &, tag &) noexcept; void handle_error(link &, const boost::system::system_error &); - void handle_error(link &, const std::exception &); + void handle_error(link &, std::exception_ptr); void handle_close(link &, std::exception_ptr); void handle_open(link &, std::exception_ptr); diff --git a/ircd/server.cc b/ircd/server.cc index c3a461d73..851d64afd 100644 --- a/ircd/server.cc +++ b/ircd/server.cc @@ -466,15 +466,19 @@ catch(const std::exception &e) void ircd::server::node::handle_error(link &link, - const std::exception &e) + std::exception_ptr eptr) +try +{ + cancel_committed(link, eptr); + link.close(net::dc::RST); + std::rethrow_exception(eptr); +} +catch(const std::exception &e) { log.error("node(%p) link(%p): %s", this, &link, e.what()); - - cancel_committed(link, e); - link.close(net::dc::RST); } void @@ -563,17 +567,17 @@ void ircd::server::node::disperse(link &link) { disperse_uncommitted(link); - cancel_committed(link, canceled + cancel_committed(link, std::make_exception_ptr(canceled { "Request was partially completed when fatal error occurred" - }); + })); assert(link.queue.empty()); } void ircd::server::node::cancel_committed(link &link, - const std::exception &e) + std::exception_ptr eptr) { auto &queue(link.queue); @@ -587,13 +591,13 @@ ircd::server::node::cancel_committed(link &link, }) }; - std::for_each(begin(queue), it, [this, &e](auto &tag) + std::for_each(begin(queue), it, [this, &eptr](auto &tag) { if(!tag.request) return; assert(tag.write_completed()); - tag.set_exception(e); + tag.set_exception(eptr); disassociate(*tag.request, tag); }); @@ -1140,7 +1144,7 @@ catch(const std::exception &e) { if(node) { - node->handle_error(*this, e); + node->handle_error(*this, std::make_exception_ptr(std::current_exception())); return; }