summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2015-07-28 19:11:34 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-29 02:12:19 +0000
commita17d003d9ad2131c174e0e6faaf66362311381cc (patch)
tree150318365665780bd10e466abe07fd5e1d753817 /base
parent9f01b7728bf46829d9a025c9f595d02554d5de1f (diff)
downloadchromium_src-a17d003d9ad2131c174e0e6faaf66362311381cc.zip
chromium_src-a17d003d9ad2131c174e0e6faaf66362311381cc.tar.gz
chromium_src-a17d003d9ad2131c174e0e6faaf66362311381cc.tar.bz2
POSIX: Delete ThreadParams on newly created threads ASAP.
Make the scoped_ptr that owns the ThreadParams* go out of scope sooner. Otherwise, Valgrind seems to get confused and believe it leaks. BUG=514868 Review URL: https://codereview.chromium.org/1261223002 Cr-Commit-Position: refs/heads/master@{#340839}
Diffstat (limited to 'base')
-rw-r--r--base/threading/platform_thread_posix.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc
index 3c1d1a8..61d7586 100644
--- a/base/threading/platform_thread_posix.cc
+++ b/base/threading/platform_thread_posix.cc
@@ -43,14 +43,19 @@ struct ThreadParams {
void* ThreadFunc(void* params) {
base::InitOnThread();
- scoped_ptr<ThreadParams> thread_params(static_cast<ThreadParams*>(params));
- PlatformThread::Delegate* delegate = thread_params->delegate;
- if (!thread_params->joinable)
- base::ThreadRestrictions::SetSingletonAllowed(false);
+ PlatformThread::Delegate* delegate = nullptr;
- if (thread_params->priority != ThreadPriority::NORMAL)
- PlatformThread::SetCurrentThreadPriority(thread_params->priority);
+ {
+ scoped_ptr<ThreadParams> thread_params(static_cast<ThreadParams*>(params));
+
+ delegate = thread_params->delegate;
+ if (!thread_params->joinable)
+ base::ThreadRestrictions::SetSingletonAllowed(false);
+
+ if (thread_params->priority != ThreadPriority::NORMAL)
+ PlatformThread::SetCurrentThreadPriority(thread_params->priority);
+ }
ThreadIdNameManager::GetInstance()->RegisterThread(
PlatformThread::CurrentHandle().platform_handle(),