From 87211071e446901719bcb2941f3ad507fa09e744 Mon Sep 17 00:00:00 2001 From: Sotaro Ikeda Date: Mon, 30 Jun 2014 16:36:52 -0700 Subject: [PATCH] Bug 1031527 - Remove dup fd from ParamTraits::Read(). r=jrmuizel, a=2.0+ --- gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp index cd0673614372..d883644852dd 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp +++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp @@ -54,8 +54,10 @@ ParamTraits::Read(const Message* aMsg, void** aIter, int owner; int index; if (!aMsg->ReadInt(aIter, &owner) || - !aMsg->ReadInt32(aIter, &index)) + !aMsg->ReadInt32(aIter, &index)) { + printf_stderr("ParamTraits::Read() failed to read a message\n"); return false; + } aParam->mOwner = owner; aParam->mKey = index; return true; @@ -121,6 +123,7 @@ ParamTraits::Read(const Message* aMsg, !aMsg->ReadSize(aIter, &nbytes) || !aMsg->ReadSize(aIter, &nfds) || !aMsg->ReadBytes(aIter, &data, nbytes)) { + printf_stderr("ParamTraits::Read() failed to read a message\n"); return false; } @@ -129,15 +132,16 @@ ParamTraits::Read(const Message* aMsg, for (size_t n = 0; n < nfds; ++n) { FileDescriptor fd; if (!aMsg->ReadFileDescriptor(aIter, &fd)) { + printf_stderr("ParamTraits::Read() failed to read file descriptors\n"); return false; } // If the GraphicBuffer was shared cross-process, SCM_RIGHTS does - // the right thing and dup's the fd. If it's shared cross-thread, - // SCM_RIGHTS doesn't dup the fd. That's surprising, but we just - // deal with it here. NB: only the "default" (master) process can - // alloc gralloc buffers. - int dupFd = sameProcess && index < 0 ? dup(fd.fd) : fd.fd; - fds[n] = dupFd; + // the right thing and dup's the fd. If it's shared cross-thread, + // SCM_RIGHTS doesn't dup the fd. + // But in shared cross-thread, dup fd is not necessary because we get + // a pointer to the GraphicBuffer directly from SharedBufferManagerParent + // and don't create a new GraphicBuffer around the fd. + fds[n] = fd.fd; } aResult->mRef.mOwner = owner; @@ -167,6 +171,7 @@ ParamTraits::Read(const Message* aMsg, } if (aResult->mGraphicBuffer == nullptr) { + printf_stderr("ParamTraits::Read() failed to get gralloc buffer\n"); return false; } -- 2.11.4.GIT