From 71bc3b2b02bdf75f04e672c5e1e77999a124b536 Mon Sep 17 00:00:00 2001 From: erikchen Date: Mon, 1 Feb 2016 14:14:28 -0800 Subject: Add member ownership_passes_to_ipc_ to SharedMemoryHandle on windows. Prior to attachment brokering, the semantics for SharedMemoryHandle differed between Windows and other platforms. On other platforms, if a handle is passed to the IPC stack, there is a flag that indicates whether ownership also passed. On Windows, there was no flag, and whether ownership was passed, or leaked (waiting for another process to close it), was entirely context dependent. Adding this flag to attachment-brokered SharedMemoryHandles on Windows mean that they now have the same ownership semantics as SharedMemoryHandles on other platforms. BUG=580636 Review URL: https://codereview.chromium.org/1643253003 Cr-Commit-Position: refs/heads/master@{#372783} --- ipc/ipc_message_utils.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ipc') diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc index ea88b55..277c2ff 100644 --- a/ipc/ipc_message_utils.cc +++ b/ipc/ipc_message_utils.cc @@ -665,6 +665,11 @@ void ParamTraits::Write(Message* m, if (p.NeedsBrokering()) { HandleWin handle_win(p.GetHandle(), HandleWin::DUPLICATE); ParamTraits::Write(m, handle_win); + + // If the caller intended to pass ownership to the IPC stack, release a + // reference. + if (p.OwnershipPassesToIPC()) + p.Close(); } else { m->WriteInt(HandleToLong(p.GetHandle())); } -- cgit v1.1