mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 21:20:18 +08:00
Fix for a potential data race condition
This commit is contained in:
parent
ff6881efbf
commit
993e0b0bf9
@ -286,6 +286,13 @@ void* cv::workcycleObjectDetectorFunction(void* p)
|
|||||||
try{
|
try{
|
||||||
((cv::DetectionBasedTracker::SeparateDetectionWork*)p)->lock();
|
((cv::DetectionBasedTracker::SeparateDetectionWork*)p)->lock();
|
||||||
((cv::DetectionBasedTracker::SeparateDetectionWork*)p)->stateThread = cv::DetectionBasedTracker::SeparateDetectionWork::STATE_THREAD_STOPPED;
|
((cv::DetectionBasedTracker::SeparateDetectionWork*)p)->stateThread = cv::DetectionBasedTracker::SeparateDetectionWork::STATE_THREAD_STOPPED;
|
||||||
|
((cv::DetectionBasedTracker::SeparateDetectionWork*)p)->isObjectDetectingReady=false;
|
||||||
|
((cv::DetectionBasedTracker::SeparateDetectionWork*)p)->shouldObjectDetectingResultsBeForgot=false;
|
||||||
|
#ifdef USE_STD_THREADS
|
||||||
|
objectDetectorThreadStartStop.notify_one();
|
||||||
|
#else
|
||||||
|
pthread_cond_signal(&objectDetectorThreadStartStop);
|
||||||
|
#endif
|
||||||
((cv::DetectionBasedTracker::SeparateDetectionWork*)p)->unlock();
|
((cv::DetectionBasedTracker::SeparateDetectionWork*)p)->unlock();
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
LOGE0("DetectionBasedTracker: workcycleObjectDetectorFunction: ERROR concerning pointer, received as the function parameter");
|
LOGE0("DetectionBasedTracker: workcycleObjectDetectorFunction: ERROR concerning pointer, received as the function parameter");
|
||||||
@ -439,25 +446,6 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()
|
|||||||
objects.clear();
|
objects.clear();
|
||||||
}// while(isWorking())
|
}// while(isWorking())
|
||||||
|
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
mtx_lock.lock();
|
|
||||||
#else
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
stateThread=STATE_THREAD_STOPPED;
|
|
||||||
|
|
||||||
isObjectDetectingReady=false;
|
|
||||||
shouldObjectDetectingResultsBeForgot=false;
|
|
||||||
|
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
objectDetectorThreadStartStop.notify_one();
|
|
||||||
mtx_lock.unlock();
|
|
||||||
#else
|
|
||||||
pthread_cond_signal(&objectDetectorThreadStartStop);
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LOGI("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector: Returning");
|
LOGI("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector: Returning");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user