Re: [asio-users] win_iocp_io_service::shutdown_service() locks on timer_thread_->join()
Brought to you by:
chris_kohlhoff
From: Daniele B. <dan...@eu...> - 2011-01-20 11:49:14
|
>> All seems to work: the CWorker destructor is called but the call to >> CoUninitialize() locks! >> Here the Threads when the lock occur: > > Do you really have some com ptrs marshalled from the main thread? Hi Igor! This is the fact...I THINK no. The deadlock happen also if I remove the CoInitialize/CoUninitialize. (I call these functions to post events from my C++ Object to the COM object). My COM wrapper only create an object using the factory function from my LIB: HRESULT CTETRAMoto::FinalConstruct() { _devTetra.reset( EuroATLib::GetTETRAMotoObj() ); } and that's it. Then inside the LIB, at the first object creation, a worker thread is started...but no COM object 'live' into that thread! Debugging a little deeper I see that, when the io_service.run() returns, the Main thread is looped in win_iocp_io_service::shutdown_service() at: while (::InterlockedExchangeAdd(&outstanding_work_, 0) > 0) { ... } which never ends. If I force the flow to go ahead, there is the timer_thread_->join() instruction which calls ::WaitForSingleObject(thread_, INFINITE) which, in turn, lock the main thread! Suggestions? Daniele. |