From 2c98af7935cdde77c0ded19dd4fa260a2fa4bc47 Mon Sep 17 00:00:00 2001 From: "fischman@webrtc.org" Date: Wed, 14 May 2014 17:33:32 +0000 Subject: [PATCH] PeerConnection(Java): auto-WrapCurrentThread() when creating PeerConnectionFactory. Various pieces of talk/ assume that the current Thread is ThreadManager'd without checking this, so unconditionally wrap the caller's thread in case it was created by Java code unbeknownst to ThreadManager. BUG=2947 R=wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/9419004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6154 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/app/webrtc/java/jni/peerconnection_jni.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/talk/app/webrtc/java/jni/peerconnection_jni.cc b/talk/app/webrtc/java/jni/peerconnection_jni.cc index 9739c8924d..364d1963b0 100644 --- a/talk/app/webrtc/java/jni/peerconnection_jni.cc +++ b/talk/app/webrtc/java/jni/peerconnection_jni.cc @@ -1928,6 +1928,12 @@ class OwnedFactoryAndThreads { JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnectionFactory)( JNIEnv* jni, jclass) { + // talk/ assumes pretty widely that the current Thread is ThreadManager'd, but + // ThreadManager only WrapCurrentThread()s the thread where it is first + // created. Since the semantics around when auto-wrapping happens in + // talk/base/ are convoluted, we simply wrap here to avoid having to think + // about ramifications of auto-wrapping there. + talk_base::ThreadManager::Instance()->WrapCurrentThread(); webrtc::Trace::CreateTrace(); Thread* worker_thread = new Thread(); worker_thread->SetName("worker_thread", NULL);