Commit b5cdc03b authored by Andrey Pavlenko's avatar Andrey Pavlenko Committed by OpenCV Buildbot

Merge pull request #1972 from alalek:ocl_queue_cleanup_hung

parents d802b4d1 bdbd3eb2
......@@ -1932,10 +1932,15 @@ struct Queue::Impl
~Impl()
{
if(handle)
#ifdef _WIN32
if (!cv::__termination)
#endif
{
clFinish(handle);
clReleaseCommandQueue(handle);
if(handle)
{
clFinish(handle);
clReleaseCommandQueue(handle);
}
}
}
......
......@@ -249,6 +249,9 @@ namespace ocl
MatAllocator* getOpenCLAllocator();
}
extern bool __termination; // skip some cleanups, because process is terminating
// (for example, if ExitProcess() was already called)
}
#endif /*_CXCORE_INTERNAL_H_*/
......@@ -734,18 +734,23 @@ cvErrorFromIppStatus( int status )
}
}
namespace cv {
bool __termination = false;
}
#if defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
#ifdef HAVE_WINRT
#pragma warning(disable:4447) // Disable warning 'main' signature found without threading model
#endif
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID );
BOOL WINAPI DllMain( HINSTANCE, DWORD, LPVOID );
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID )
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID lpReserved )
{
if( fdwReason == DLL_THREAD_DETACH || fdwReason == DLL_PROCESS_DETACH )
{
if (lpReserved != NULL) // called after ExitProcess() call
cv::__termination = true;
cv::deleteThreadAllocData();
cv::deleteThreadData();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment