From 003ecf635784b0c0281b02ec0e1c54544db50241 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 6 May 2018 01:15:26 -0700 Subject: [PATCH] ircd: Remove / update various ctx::interrupted catch blocks for ctx::terminated. --- ircd/aio.cc | 5 +++++ ircd/client.cc | 4 ---- ircd/ctx.cc | 32 ++++++++++++++++++++------------ ircd/ircd.cc | 13 ++----------- ircd/m/m.cc | 4 ---- ircd/net.cc | 10 ---------- modules/client/profile.cc | 4 ---- modules/client/rooms/typing.cc | 8 -------- modules/federation/sender.cc | 32 ++------------------------------ modules/m_presence.cc | 4 ---- 10 files changed, 29 insertions(+), 87 deletions(-) diff --git a/ircd/aio.cc b/ircd/aio.cc index c4a0600a2..ccfd60a55 100644 --- a/ircd/aio.cc +++ b/ircd/aio.cc @@ -261,6 +261,11 @@ catch(const ctx::interrupted &e) cancel(); throw; } +catch(const ctx::terminated &) +{ + cancel(); + throw; +} /////////////////////////////////////////////////////////////////////////////// // diff --git a/ircd/client.cc b/ircd/client.cc index 9f4b84a31..1e5916e7b 100644 --- a/ircd/client.cc +++ b/ircd/client.cc @@ -783,10 +783,6 @@ try return ret; } -catch(const ctx::interrupted &e) -{ - throw; -} catch(const boost::system::system_error &e) { if(e.code().value() != boost::system::errc::operation_canceled) diff --git a/ircd/ctx.cc b/ircd/ctx.cc index 483ca794b..b896bc6db 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -70,12 +70,19 @@ noexcept try if(likely(bool(func))) func(); } +catch(const ircd::ctx::interrupted &) +{ + return; +} +catch(const ircd::ctx::terminated &) +{ + return; +} catch(const std::exception &e) { log::critical { - "ctx(%p '%s' #%u): unhandled: %s", - current, + "ctx('%s' #%u): unhandled: %s", name, id, e.what() @@ -88,10 +95,6 @@ catch(const std::exception &e) // handling the exception here with a log message and calling it a day. return; } -catch(const terminated &) -{ - return; -} /// Direct context switch to this context. /// @@ -913,12 +916,17 @@ noexcept try } catch(const interrupted &e) { -/* - log::debug - { - "pool(%p) ctx(%p): %s", this, &cur(), e.what() - }; -*/ +// log::debug +// { +// "pool(%p) ctx(%p): %s", this, &cur(), e.what() +// }; +} +catch(const terminated &e) +{ +// log::debug +// { +// "pool(%p) ctx(%p): %s", this, &cur(), e.what() +// }; } void diff --git a/ircd/ircd.cc b/ircd/ircd.cc index 1d9895aa0..e0f526aa0 100644 --- a/ircd/ircd.cc +++ b/ircd/ircd.cc @@ -235,11 +235,11 @@ noexcept try // executes backwards from this point and shuts down IRCd. ctx::wait(); } -catch(const ctx::interrupted &e) +catch(const ctx::terminated &) { log::warning { - "IRCd main interrupted..." + "IRCd main terminated..." }; } catch(const std::exception &e) @@ -249,15 +249,6 @@ catch(const std::exception &e) "IRCd main exited: %s", e.what() }; } -catch(const ctx::terminated &) -{ - log::warning - { - "IRCd main terminated..." - }; - - throw; -} void ircd::at_main_exit() diff --git a/ircd/m/m.cc b/ircd/m/m.cc index bf1d3f688..9a8bcbc28 100644 --- a/ircd/m/m.cc +++ b/ircd/m/m.cc @@ -2546,10 +2546,6 @@ try { hook.function(event); } -catch(const ctx::interrupted &e) -{ - throw; -} catch(const std::exception &e) { log::critical diff --git a/ircd/net.cc b/ircd/net.cc index a7078b9e9..685c1e920 100644 --- a/ircd/net.cc +++ b/ircd/net.cc @@ -2849,7 +2849,6 @@ noexcept void ircd::net::dns::resolver::sendq_worker() -try { while(1) { @@ -2869,10 +2868,6 @@ try sendq.pop_front(); } } -catch(const ctx::interrupted &) -{ - return; -} void ircd::net::dns::resolver::flush(const queued &next) @@ -2900,7 +2895,6 @@ catch(const std::out_of_range &e) void ircd::net::dns::resolver::timeout_worker() -try { while(1) { @@ -2913,10 +2907,6 @@ try check_timeouts(milliseconds(timeout)); } } -catch(const ctx::interrupted &) -{ - return; -} void ircd::net::dns::resolver::check_timeouts(const milliseconds &timeout) diff --git a/modules/client/profile.cc b/modules/client/profile.cc index a34c9fca0..1365b254c 100644 --- a/modules/client/profile.cc +++ b/modules/client/profile.cc @@ -327,10 +327,6 @@ try { m::join(room, user); } -catch(const ctx::interrupted &e) -{ - throw; -} catch(const std::exception &e) { log::error diff --git a/modules/client/rooms/typing.cc b/modules/client/rooms/typing.cc index ba5ec68d5..daa0932e2 100644 --- a/modules/client/rooms/typing.cc +++ b/modules/client/rooms/typing.cc @@ -185,7 +185,6 @@ calc_timesout(const resource::request &request) void timeout_worker() -try { while(1) { @@ -198,13 +197,6 @@ try ctx::sleep(seconds(5)); } } -catch(const ctx::interrupted &) -{ - log::debug - { - "Typing timeout worker interrupted" - }; -} void timeout_check() diff --git a/modules/federation/sender.cc b/modules/federation/sender.cc index 6dca29673..1c665c95d 100644 --- a/modules/federation/sender.cc +++ b/modules/federation/sender.cc @@ -44,8 +44,8 @@ IRCD_MODULE "federation sender", nullptr, [] { - sender.interrupt(); - receiver.interrupt(); + sender.terminate(); + receiver.terminate(); sender.join(); receiver.join(); } @@ -53,7 +53,6 @@ IRCD_MODULE void send_worker() -try { // In order to synchronize with the vm core, this context has to // maintain this shared_lock at all times. If this is unlocked we @@ -74,10 +73,6 @@ try if(my(event)) send(event); } - catch(const ircd::ctx::interrupted &e) - { - throw; - } catch(const std::exception &e) { log::error @@ -86,13 +81,6 @@ try }; } } -catch(const ircd::ctx::interrupted &e) -{ - log::debug - { - "Sender worker interrupted..." - }; -} void send(const m::event &event) @@ -221,7 +209,6 @@ catch(const std::exception &e) void recv_worker() -try { while(1) { @@ -234,13 +221,6 @@ try recv_timeouts(); } } -catch(const ircd::ctx::interrupted &e) -{ - log::debug - { - "Receive worker interrupted..." - }; -} void recv() @@ -288,10 +268,6 @@ try node.flush(); } -catch(const ctx::interrupted &e) -{ - throw; -} catch(const std::exception &e) { ircd::assertion(e); @@ -345,10 +321,6 @@ try return true; } -catch(const ctx::interrupted &e) -{ - throw; -} catch(const http::error &e) { log::derror diff --git a/modules/m_presence.cc b/modules/m_presence.cc index 65de3fa18..6f96e7eed 100644 --- a/modules/m_presence.cc +++ b/modules/m_presence.cc @@ -65,10 +65,6 @@ try for(const json::object &presence : push) handle_edu_m_presence_(event, presence); } -catch(const ctx::interrupted &) -{ - throw; -} catch(const std::exception &e) { log::derror