From cfda7e2260ac6ece0d65bc1db650318c19e613f2 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 7 Apr 2020 10:28:46 -0700 Subject: [PATCH] client: trap error in close() --- src/client.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 624e065..c1c79bd 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -234,8 +234,15 @@ Context::Context(const Config& conf) // external pvt.reset(internal.get(), [internal](Pvt*) mutable { - internal->close(); - internal.reset(); + auto temp(std::move(internal)); + try { + temp->close(); + }catch(std::exception& e){ + // called through ~shared_ptr and can't propagate exceptions. + // log and continue... + log_exc_printf(setup, "Error while closing Context (%s) : %s\n", + typeid(e).name(), e.what()); + } cnt_ClientPvtLive.fetch_sub(1u); }); // we don't keep a weak_ptr to the external reference.