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

Unified Diff: mojo/edk/system/node_controller.cc

Issue 2111453002: [mojo-edk] Duplicate process handle and take ownership in NodeChannel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « mojo/edk/system/node_channel.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/node_controller.cc
diff --git a/mojo/edk/system/node_controller.cc b/mojo/edk/system/node_controller.cc
index 07108b849be825e3bf7935e8e0ba3ce8e7369c39..5fc55f557d7063cd50071b398a17f90bdc5d320d 100644
--- a/mojo/edk/system/node_controller.cc
+++ b/mojo/edk/system/node_controller.cc
@@ -179,6 +179,19 @@ void NodeController::ConnectToChild(
DCHECK(inserted);
}
+#if defined(OS_WIN)
+ // On Windows, we need to duplicate the process handle because we have no
+ // control over its lifetime and it may become invalid by the time the posted
+ // task runs.
+ HANDLE dup_handle = INVALID_HANDLE_VALUE;
+ BOOL ok = ::DuplicateHandle(
+ base::GetCurrentProcessHandle(), process_handle,
+ base::GetCurrentProcessHandle(), &dup_handle,
+ 0, FALSE, DUPLICATE_SAME_ACCESS);
+ DPCHECK(ok);
+ process_handle = dup_handle;
+#endif
+
io_task_runner_->PostTask(
FROM_HERE,
base::Bind(&NodeController::ConnectToChildOnIOThread,
« no previous file with comments | « mojo/edk/system/node_channel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698