COM-110: Catch engine session in adapter destructor so it can be destroyed gracefully sync Release_2.0.0
authorAlex Sualdea
Mon, 02 Mar 2020 12:13:36 +0100
branchsync
changeset 387bef6f1b3af88
parent 386 b5708ceb42b7
child 388 82731e50c0d7
child 389 6539f37cb60b
child 394 4076d056086c
COM-110: Catch engine session in adapter destructor so it can be destroyed gracefully
CpEpEngine.h
     1.1 --- a/CpEpEngine.h	Fri Feb 07 08:28:05 2020 +0100
     1.2 +++ b/CpEpEngine.h	Mon Mar 02 12:13:36 2020 +0100
     1.3 @@ -49,7 +49,17 @@
     1.4          --count;
     1.5          if (!count) {
     1.6              StopKeyserverLookup();
     1.7 -            ::log_event(session(), "Shutdown", "pEp COM Adapter", NULL, NULL);
     1.8 +            try {
     1.9 +                // try/catch to avoid freeze when no session could be initialized because a runtime
    1.10 +                // or other kind of exceptions thrown by engine
    1.11 +                ::log_event(session(), "Shutdown", "pEp COM Adapter", NULL, NULL);
    1.12 +            }
    1.13 +            catch (pEp::RuntimeError& ex) { // runtime
    1.14 +                error(ex.what());
    1.15 +            }
    1.16 +            catch (std::exception& ex) { // bad alloc or invalid argument
    1.17 +                error(ex.what());
    1.18 +            }
    1.19              session(pEp::Adapter::release);
    1.20              shutdown();
    1.21