The previous code attempted to lock instance_count and instance with a CriticalSection, but the CriticalSection was not static, so each function invocation got its own instance. Locking this call-specific instance doesn't actually stop any other threads from concurrently accessing the same function-scope globals, so this function had a data race, which broke tsan tests (and possibly other things). Making the CriticalSection shared among function calls will actually synchronize access to the globals and allow our tsan tests to pass. BUG=webrtc:3062 Review-Url: https://codereview.webrtc.org/2890213002 Cr-Commit-Position: refs/heads/master@{#18296}
Name: WebRTC URL: http://www.webrtc.org Version: 90 License: BSD License File: LICENSE Description: WebRTC provides real time voice and video processing functionality to enable the implementation of PeerConnection/MediaStream. Third party code used in this project is described in the file LICENSE_THIRD_PARTY.