diff options
author | thestig <thestig@chromium.org> | 2015-07-28 19:11:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-29 02:12:19 +0000 |
commit | a17d003d9ad2131c174e0e6faaf66362311381cc (patch) | |
tree | 150318365665780bd10e466abe07fd5e1d753817 | |
parent | 9f01b7728bf46829d9a025c9f595d02554d5de1f (diff) | |
download | chromium_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}
-rw-r--r-- | base/threading/platform_thread_posix.cc | 17 |
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(), |