| Index: third_party/libjingle/files/talk/base/thread.cc
|
| ===================================================================
|
| --- third_party/libjingle/files/talk/base/thread.cc (revision 28631)
|
| +++ third_party/libjingle/files/talk/base/thread.cc (working copy)
|
| @@ -106,6 +106,7 @@
|
| Thread::Thread(SocketServer* ss) : MessageQueue(ss), priority_(PRIORITY_NORMAL) {
|
| g_thmgr.Add(this);
|
| started_ = false;
|
| + stopped_ = false;
|
| has_sends_ = false;
|
| }
|
|
|
| @@ -127,12 +128,16 @@
|
| pthread_attr_setschedparam(&attr, ¶m);
|
| }
|
| CritScope cs(&started_crit_);
|
| + // Make sure Join() hasn't been called yet.
|
| + if (stopped_)
|
| + return;
|
| pthread_create(&thread_, &attr, PreRun, this);
|
| started_ = true;
|
| }
|
|
|
| void Thread::Join() {
|
| CritScope cs(&started_crit_);
|
| + stopped_ = true;
|
| if (started_) {
|
| void *pv;
|
| pthread_join(thread_, &pv);
|
| @@ -174,6 +179,9 @@
|
| flags = CREATE_SUSPENDED;
|
| }
|
| CritScope cs(&started_crit_);
|
| + // Make sure Join() hasn't been called yet.
|
| + if (stopped_)
|
| + return;
|
| thread_ = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PreRun, this, flags, NULL);
|
| if (thread_) {
|
| if (priority_ != PRIORITY_NORMAL) {
|
| @@ -188,6 +196,7 @@
|
|
|
| void Thread::Join() {
|
| CritScope cs(&started_crit_);
|
| + stopped_ = true;
|
| if (started_) {
|
| WaitForSingleObject(thread_, INFINITE);
|
| CloseHandle(thread_);
|
|
|