Index: src/liblogger/TAsyncMultiLogger.cpp =================================================================== diff -u -rebc7fabbd2d59f9a0f723ea480b5374cc393ec12 -raa18f0444eecb7f31ecc142bf53509c48ac77b35 --- src/liblogger/TAsyncMultiLogger.cpp (.../TAsyncMultiLogger.cpp) (revision ebc7fabbd2d59f9a0f723ea480b5374cc393ec12) +++ src/liblogger/TAsyncMultiLogger.cpp (.../TAsyncMultiLogger.cpp) (revision aa18f0444eecb7f31ecc142bf53509c48ac77b35) @@ -95,47 +95,53 @@ ResetEvent(pAsyncLogger->m_spStoppedEvent.get()); - std::vector vHandles; - - bool bStopProcessing = false; - do + try { - { - boost::unique_lock lock(pAsyncLogger->m_mutex); - vHandles.clear(); - vHandles.push_back(pAsyncLogger->m_spStopEvent.get()); + std::vector vHandles; - std::transform(pAsyncLogger->m_setLoggerData.begin(), pAsyncLogger->m_setLoggerData.end(), std::back_inserter(vHandles), [](const TLogFileDataPtr& rData) { return rData->GetEntriesEvent().get(); }); - } - - DWORD dwWaitResult = WaitForMultipleObjectsEx(boost::numeric_cast(vHandles.size()), &vHandles[ 0 ], FALSE, 500, FALSE); - if(dwWaitResult == WAIT_OBJECT_0) + bool bStopProcessing = false; + do { - bStopProcessing = true; - break; - } + { + boost::unique_lock lock(pAsyncLogger->m_mutex); + vHandles.clear(); + vHandles.push_back(pAsyncLogger->m_spStopEvent.get()); - std::vector vLogs; - { - boost::shared_lock lock(pAsyncLogger->m_mutex); - vLogs.insert(vLogs.begin(), pAsyncLogger->m_setLoggerData.begin(), pAsyncLogger->m_setLoggerData.end()); - } + std::transform(pAsyncLogger->m_setLoggerData.begin(), pAsyncLogger->m_setLoggerData.end(), std::back_inserter(vHandles), [](const TLogFileDataPtr& rData) { return rData->GetEntriesEvent().get(); }); + } - for (const TLogFileDataPtr& spLogData : vLogs) - { - try + DWORD dwWaitResult = WaitForMultipleObjectsEx(boost::numeric_cast(vHandles.size()), &vHandles[ 0 ], FALSE, 500, FALSE); + if(dwWaitResult == WAIT_OBJECT_0) { - spLogData->StoreLogEntries(); - spLogData->CloseUnusedFile(); + bStopProcessing = true; + break; } - catch (const std::exception& e) + + std::vector vLogs; { - e; - ATLTRACE(e.what()); + boost::shared_lock lock(pAsyncLogger->m_mutex); + vLogs.insert(vLogs.begin(), pAsyncLogger->m_setLoggerData.begin(), pAsyncLogger->m_setLoggerData.end()); } + + for(const TLogFileDataPtr& spLogData : vLogs) + { + try + { + spLogData->StoreLogEntries(); + spLogData->CloseUnusedFile(); + } + catch(const std::exception& e) + { + e; + ATLTRACE(e.what()); + } + } } + while(!bStopProcessing); } - while(!bStopProcessing); + catch(const std::exception&) + { + } SetEvent(pAsyncLogger->m_spStoppedEvent.get()); return 0;