From 42694c5937bc0c7c0c3e9593778ca46996c47a06 Mon Sep 17 00:00:00 2001 From: "fischman@webrtc.org" Date: Fri, 6 Jun 2014 18:28:28 +0000 Subject: [PATCH] VideoCaptureImpl::IncomingFrame(): avoid deadlock by acquiring _apiCs. Since VCI::IF() fires a callback it risks a call back into VCI on the same stack. Failing to acquire _apiCs before _callbackCs means this is a lock inversion and deadlock results. By acquiring _apiCs first no lock inversion occurs and the deadlock is removed. BUG=3434 R=mflodman@webrtc.org Review URL: https://webrtc-codereview.appspot.com/14629004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6353 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/video_capture/video_capture_impl.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webrtc/modules/video_capture/video_capture_impl.cc b/webrtc/modules/video_capture/video_capture_impl.cc index d413f5048..6f179e2da 100644 --- a/webrtc/modules/video_capture/video_capture_impl.cc +++ b/webrtc/modules/video_capture/video_capture_impl.cc @@ -260,7 +260,8 @@ int32_t VideoCaptureImpl::IncomingFrame( const VideoCaptureCapability& frameInfo, int64_t captureTime/*=0*/) { - CriticalSectionScoped cs(&_callBackCs); + CriticalSectionScoped cs(&_apiCs); + CriticalSectionScoped cs2(&_callBackCs); const int32_t width = frameInfo.width; const int32_t height = frameInfo.height; @@ -332,7 +333,8 @@ int32_t VideoCaptureImpl::IncomingFrame( int32_t VideoCaptureImpl::IncomingI420VideoFrame(I420VideoFrame* video_frame, int64_t captureTime) { - CriticalSectionScoped cs(&_callBackCs); + CriticalSectionScoped cs(&_apiCs); + CriticalSectionScoped cs2(&_callBackCs); DeliverCapturedFrame(*video_frame, captureTime); return 0;