Bug 1012639 - Fix OtherProcess sometimes being the current process handle. r=bent
authorChris Lord <chrislord.net@gmail.com>
Wed, 11 Jun 2014 14:51:12 +0100
changeset 208992 22cf4fda6c8d6aae43f7023a8d627282af1f206c
parent 208991 ae9b6e0ddc0001925c7df208473a6bbca7dfe6dd
child 208993 e7537b4f7a6c44b2fa7dc07b907ae1d57807b6dd
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs1012639
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1012639 - Fix OtherProcess sometimes being the current process handle. r=bent
ipc/glue/Shmem.cpp
ipc/ipdl/ipdl/lower.py
--- a/ipc/glue/Shmem.cpp
+++ b/ipc/glue/Shmem.cpp
@@ -618,16 +618,21 @@ Shmem::GetSysVID() const
 
 IPC::Message*
 Shmem::ShareTo(IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead,
                base::ProcessHandle aProcess,
                int32_t routingId)
 {
   AssertInvariants();
 
+  // kInvalidProcessHandle is used to indicate that it's the same process.
+  if (aProcess == kInvalidProcessHandle) {
+    aProcess = base::GetCurrentProcessHandle();
+  }
+
   if (SharedMemory::TYPE_BASIC == mSegment->Type()) {
     SharedMemoryBasic* seg = static_cast<SharedMemoryBasic*>(mSegment);
     SharedMemoryBasic::Handle handle;
     if (!seg->ShareToProcess(aProcess, &handle))
       return 0;
 
     return new ShmemCreated(routingId, mId, mSize, handle);
   }
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -2956,17 +2956,17 @@ class _GenerateProtocolActorCode(ipdl.as
                              Param(Type('MessageLoop', ptr=True),
                                    aMessageLoop.name),
                              Param(Type('mozilla::ipc::Side'),
                                    sidevar.name,
                                    default=ExprVar('mozilla::ipc::UnknownSide')) ],
                     ret=Type.BOOL))
 
             openmeth.addstmts([
-                StmtExpr(ExprAssn(p.otherProcessVar(), ExprCall(ExprVar('base::GetCurrentProcessHandle')))),
+                StmtExpr(ExprAssn(p.otherProcessVar(), ExprVar('ipc::kInvalidProcessHandle'))),
                 StmtReturn(ExprCall(ExprSelect(p.channelVar(), '.', 'Open'),
                                     [ aChannel, aMessageLoop, sidevar ]))
             ])
             self.cls.addstmts([
                 openmeth,
                 Whitespace.NL ])
 
             # Close()