Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1101)

Unified Diff: third_party/libjingle/files/talk/base/thread.cc

Issue 274079: Prevent thread creation if Join has already been called.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libjingle/files/talk/base/thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, &param);
}
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_);
« no previous file with comments | « third_party/libjingle/files/talk/base/thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698