summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorerikchen <erikchen@chromium.org>2016-02-01 14:14:28 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-01 22:15:44 +0000
commit71bc3b2b02bdf75f04e672c5e1e77999a124b536 (patch)
treeb852da80665ded5e1655678adda20349a648bb08 /ipc
parenta4bb2ccbb115eebff01bc4460cf880682668249f (diff)
downloadchromium_src-71bc3b2b02bdf75f04e672c5e1e77999a124b536.zip
chromium_src-71bc3b2b02bdf75f04e672c5e1e77999a124b536.tar.gz
chromium_src-71bc3b2b02bdf75f04e672c5e1e77999a124b536.tar.bz2
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}
Diffstat (limited to 'ipc')
-rw-r--r--ipc/ipc_message_utils.cc5
1 files changed, 5 insertions, 0 deletions
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<base::SharedMemoryHandle>::Write(Message* m,
if (p.NeedsBrokering()) {
HandleWin handle_win(p.GetHandle(), HandleWin::DUPLICATE);
ParamTraits<HandleWin>::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()));
}