std::memcpy -> memcpy for instance. This change was motivated by a
compile report complaining that std::rand() was used instead of rand(),
probably with a stdlib.h include instead of cstdlib. Use of C functions
without the std:: prefix is a lot more common, so removing std:: to
address this.
BUG=
R=tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/9559004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5657 4adac7df-926f-26a2-2b94-8c16560cd09d
Android's JVM requires threads to detach before they exit, but ONLY if
they needed to AttachCurrentThread. Conversly, threads that were
attached by the JVM (e.g. the result of making a native call from Java)
must NOT be detached by the application. This is bug 2441.
The fix for the above is to only pthread_setspecific() for threads that
Attach(), not for already-attached threads. To ensure that we only
detach Attached threads, added a GetEnv() call to ThreadDestructor(),
which revealed that Oracle's JVM can overly-eagerly clear TLS accounting
data, effectively detaching threads without their consent at shutdown.
Work around this with a specific check.
To guard against (some) regression, added a variant of PeerConnectionTest
that runs on a non-main thread. This revealed a bug in LinuxDeviceManager
which implicitly assumes its talk_base::Thread has already been
initialized. Fixed that here too.
BUG=2441
R=henrike@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/8759004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5567 4adac7df-926f-26a2-2b94-8c16560cd09d
1) init start_time_ns_ before the file_read_thread_ is started to avoid data racing as the start_time_ns_ will also be read by the file_read_thread_.
2) add CriticalSection to protect |finished_| that is accessed by FileReadThread and the main thread
Also remove the suppression for filemediaengine.cc, which has already been fixed in other cl.
TBR=henrike@webrtc.org
TEST=try bots and manual tsan v2 test
BUG=2078
Review URL: https://webrtc-codereview.appspot.com/2509004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5018 4adac7df-926f-26a2-2b94-8c16560cd09d
Update Thread documentation, fix all subclasses that had a problem.
This is to avoid a data racing between the destructor modifying the vtable, and
Thread::PreRun calling virtual method Run at the same time.
For example:
[ RUN ] FileMediaEngineTest.TestGetCapabilities
==================
WARNING: ThreadSanitizer: data race on vptr (ctor/dtor vs virtual call) (pid=2967)
Read of size 8 at 0x7d480000bd00 by thread T1:
#0 talk_base::Thread::PreRun(void*) /mnt/data/b/build/slave/Linux_Tsan_v2/build/src/out/Release/../../talk/base/thread.cc:353 (libjingle_media_unittest+0x000000234da8)
Previous write of size 8 at 0x7d480000bd00 by main thread:
#0 talk_base::Thread::~Thread() /mnt/data/b/build/slave/Linux_Tsan_v2/build/src/out/Release/../../talk/base/thread.cc:158 (libjingle_media_unittest+0x00000023478c)
#1 ~RtpSenderReceiver /mnt/data/b/build/slave/Linux_Tsan_v2/build/src/out/Release/../../talk/media/base/filemediaengine.cc:122 (libjingle_media_unittest+0x0000001b551f)
...
RISK=P2
TESTED=try bots and tsan
BUG=2078,2080
R=fischman@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/2428004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@4999 4adac7df-926f-26a2-2b94-8c16560cd09d