summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-23 21:37:41 +0000
committerpiman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-23 21:37:41 +0000
commitbe60b9a5c94c8439c236a820505ebad04460efc0 (patch)
treefcfb2b788bba22e24d050f799e5d6edf8f61f241
parent2380f378654e66f58262e3eaa1f9ba0cd1da09e0 (diff)
downloadchromium_src-be60b9a5c94c8439c236a820505ebad04460efc0.zip
chromium_src-be60b9a5c94c8439c236a820505ebad04460efc0.tar.gz
chromium_src-be60b9a5c94c8439c236a820505ebad04460efc0.tar.bz2
Dup command-buffer SHM handle before auto-closing.
This also adds error logging to the various places we close file descriptors, to help diagnosing future similar issues. BUG=none TEST=Pepper Flash + youtube in oop with --enable-accelerated-plugins Review URL: http://codereview.chromium.org/6549037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75792 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/shared_memory_posix.cc6
-rw-r--r--base/sync_socket_posix.cc16
-rw-r--r--ppapi/proxy/ppb_context_3d_proxy.cc5
3 files changed, 19 insertions, 8 deletions
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index 843322b..cafda5a 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -79,7 +79,8 @@ SharedMemoryHandle SharedMemory::NULLHandle() {
// static
void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) {
DCHECK(handle.fd >= 0);
- close(handle.fd);
+ if (HANDLE_EINTR(close(handle.fd)) < 0)
+ PLOG(ERROR) << "close";
}
bool SharedMemory::CreateAndMapAnonymous(uint32 size) {
@@ -229,7 +230,8 @@ void SharedMemory::Close() {
Unmap();
if (mapped_file_ > 0) {
- close(mapped_file_);
+ if (HANDLE_EINTR(close(mapped_file_)) < 0)
+ PLOG(ERROR) << "close";
mapped_file_ = -1;
}
}
diff --git a/base/sync_socket_posix.cc b/base/sync_socket_posix.cc
index c2020c2..91467b1 100644
--- a/base/sync_socket_posix.cc
+++ b/base/sync_socket_posix.cc
@@ -63,10 +63,14 @@ bool SyncSocket::CreatePair(SyncSocket* pair[2]) {
return true;
cleanup:
- if (handles[0] != kInvalidHandle)
- (void) close(handles[0]);
- if (handles[1] != kInvalidHandle)
- (void) close(handles[1]);
+ if (handles[0] != kInvalidHandle) {
+ if (HANDLE_EINTR(close(handles[0])) < 0)
+ PLOG(ERROR) << "close";
+ }
+ if (handles[1] != kInvalidHandle) {
+ if (HANDLE_EINTR(close(handles[1])) < 0)
+ PLOG(ERROR) << "close";
+ }
delete tmp_sockets[0];
delete tmp_sockets[1];
return false;
@@ -76,7 +80,9 @@ bool SyncSocket::Close() {
if (handle_ == kInvalidHandle) {
return false;
}
- int retval = close(handle_);
+ int retval = HANDLE_EINTR(close(handle_));
+ if (retval < 0)
+ PLOG(ERROR) << "close";
handle_ = kInvalidHandle;
return (retval == 0);
}
diff --git a/ppapi/proxy/ppb_context_3d_proxy.cc b/ppapi/proxy/ppb_context_3d_proxy.cc
index 9c1e383..076f133 100644
--- a/ppapi/proxy/ppb_context_3d_proxy.cc
+++ b/ppapi/proxy/ppb_context_3d_proxy.cc
@@ -133,8 +133,11 @@ const PPB_Context3D_Dev context_3d_interface = {
base::SharedMemoryHandle SHMHandleFromInt(int shm_handle) {
#if defined(OS_POSIX)
- return base::FileDescriptor(shm_handle, true);
+ // The handle isn't ours to close, but we want to keep a reference to the
+ // handle until it is actually sent, so duplicate it, and mark auto-close.
+ return base::FileDescriptor(dup(shm_handle), true);
#elif defined(OS_WIN)
+ // TODO(piman): DuplicateHandle to the plugin process.
return reinterpret_cast<HANDLE>(shm_handle);
#else
#error "Platform not supported."