diff options
author | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-12 03:18:19 +0000 |
---|---|---|
committer | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-12 03:18:19 +0000 |
commit | 07cc0c29eda76b844b51682208a9eed89e9ef7fc (patch) | |
tree | 4cb2236da4097770290b2975ef3906add4a6e42e /remoting/capturer | |
parent | bbdf3313bf646b8dcedd932747327354149aacdc (diff) | |
download | chromium_src-07cc0c29eda76b844b51682208a9eed89e9ef7fc.zip chromium_src-07cc0c29eda76b844b51682208a9eed89e9ef7fc.tar.gz chromium_src-07cc0c29eda76b844b51682208a9eed89e9ef7fc.tar.bz2 |
Duplicate handles so each SharedMemory object will have its own handle.
SharedMemory assumes that it owns the handle of the shared section and closes it upon destruction. If two SharedMemory objects use the same handle value they both will try to close the handle and the 2nd attempt will fail. Usually this error is ignored but Application Verifier detects it easily.
BUG=169030
Review URL: https://chromiumcodereview.appspot.com/11833004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176496 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/capturer')
-rw-r--r-- | remoting/capturer/shared_buffer_unittest.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/remoting/capturer/shared_buffer_unittest.cc b/remoting/capturer/shared_buffer_unittest.cc index 793f080..b065f5c 100644 --- a/remoting/capturer/shared_buffer_unittest.cc +++ b/remoting/capturer/shared_buffer_unittest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/process_util.h" +#include "ipc/ipc_platform_file.h" #include "remoting/capturer/shared_buffer.h" #include "testing/gtest/include/gtest/gtest.h" @@ -26,8 +28,18 @@ TEST(SharedBufferTest, Basic) { source->set_id(kIdOne); EXPECT_EQ(source->id(), kIdOne); +#if defined(OS_POSIX) + base::PlatformFile source_handle = source->handle().fd; +#else // !defined(OS_POSIX) + base::PlatformFile source_handle = source->handle(); +#endif // !defined(OS_POSIX) + + // Duplicate the source handle. + IPC::PlatformFileForTransit copied_handle = IPC::GetFileHandleForProcess( + source_handle, base::GetCurrentProcessHandle(), false); + scoped_refptr<SharedBuffer> dest( - new SharedBuffer(kIdZero, source->handle(), kBufferSize)); + new SharedBuffer(kIdZero, copied_handle, kBufferSize)); // Make sure that the buffer is allocated, the size is recorded correctly and // its ID is reset. |