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

Unified Diff: base/threading/platform_thread_win.cc

Issue 75133004: Close duplicated handle on windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to master. Created 7 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/platform_thread_win.cc
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc
index e9752ba21394c671d1d84214e4cd65078bd940f3..e97fce278a38e1886e431fd40af671207c4605fe 100644
--- a/base/threading/platform_thread_win.cc
+++ b/base/threading/platform_thread_win.cc
@@ -10,7 +10,7 @@
#include "base/threading/thread_id_name_manager.h"
#include "base/threading/thread_restrictions.h"
#include "base/tracked_objects.h"
-
+#include "base/win/scoped_handle.h"
#include "base/win/windows_version.h"
namespace base {
@@ -54,17 +54,21 @@ DWORD __stdcall ThreadFunc(void* params) {
if (!thread_params->joinable)
base::ThreadRestrictions::SetSingletonAllowed(false);
- /* Retrieve a copy of the thread handle to use as the key in the
- * thread name mapping. */
+ // Retrieve a copy of the thread handle to use as the key in the
+ // thread name mapping.
PlatformThreadHandle::Handle platform_handle;
- DuplicateHandle(
+ if (!DuplicateHandle(
GetCurrentProcess(),
brettw 2013/12/12 21:58:29 This indentation is a bit weird. I'd do them all a
dsinclair 2013/12/13 15:44:29 Done.
GetCurrentThread(),
GetCurrentProcess(),
&platform_handle,
0,
FALSE,
- DUPLICATE_SAME_ACCESS);
+ DUPLICATE_SAME_ACCESS)) {
+ NOTREACHED();
+ }
+
+ win::ScopedHandle scoped_platform_handle(platform_handle);
ThreadIdNameManager::GetInstance()->RegisterThread(
platform_handle,
@@ -76,6 +80,7 @@ DWORD __stdcall ThreadFunc(void* params) {
ThreadIdNameManager::GetInstance()->RemoveName(
platform_handle,
PlatformThread::CurrentId());
+
brettw 2013/12/12 21:58:29 This addition seems unnecessary.
dsinclair 2013/12/13 15:44:29 Done.
return NULL;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698