start COM on sync thread sync
authorVolker Birk <vb@pep.foundation>
Mon, 22 Oct 2018 10:14:50 +0200
branchsync
changeset 30400916b0afaac
parent 303 c9b7a1d0d160
child 305 ce22219117dd
start COM on sync thread
CpEpEngine.h
     1.1 --- a/CpEpEngine.h	Sun Oct 21 22:50:54 2018 +0200
     1.2 +++ b/CpEpEngine.h	Mon Oct 22 10:14:50 2018 +0200
     1.3 @@ -87,7 +87,7 @@
     1.4          ::register_examine_function(session(), CpEpEngine::examine_identity, (void *)this);
     1.5          ::log_event(session(), "Startup", "pEp COM Adapter", NULL, NULL);
     1.6  
     1.7 -        startup<CpEpEngine>(messageToSend, notifyHandshake, messageToSend_sync, notifyHandshake_sync, this);
     1.8 +        startup<CpEpEngine>(messageToSend, notifyHandshake, messageToSend_sync, notifyHandshake_sync, this, &CpEpEngine::Startup_sync);
     1.9  
    1.10          return S_OK;
    1.11      }
    1.12 @@ -130,6 +130,13 @@
    1.13  
    1.14      static pEp::pc_container< MarshaledCallbacks, IpEpEngineCallbacks > sync_callbacks;
    1.15  
    1.16 +    void Startup_sync()
    1.17 +    {
    1.18 +        HRESULT r = CoInitializeEx(NULL, COINIT_MULTITHREADED);
    1.19 +        if (!SUCCEEDED(r))
    1.20 +            throw runtime_error("CoInitializeEx() failed on sync thread");
    1.21 +    }
    1.22 +
    1.23      atomic< identity_queue_t * > identity_queue;
    1.24      thread *keymanagement_thread;
    1.25      bool verbose_mode;