Bug 1519728 - Fix problem passing file handles to recording process, r=kershaw.
authorBrian Hackett <bhackett1024@gmail.com>
Mon, 14 Jan 2019 05:12:40 -1000
changeset 510873 4d7150b71e09bed644881a9ea3f8d12a4be6adda
parent 510822 500d91e30e9dcbe4b6a9a908899de5629a2f9083
child 510874 5214852dfc3c9a6a53e49225360bec20abe84dcc
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskershaw
bugs1519728
milestone66.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 1519728 - Fix problem passing file handles to recording process, r=kershaw.
ipc/glue/ProcessUtils.h
ipc/glue/ProcessUtils_common.cpp
--- a/ipc/glue/ProcessUtils.h
+++ b/ipc/glue/ProcessUtils.h
@@ -58,16 +58,17 @@ class SharedPreferenceDeserializer final
   const FileDescriptor& GetPrefMapHandle() const;
 
  private:
   DISALLOW_COPY_AND_ASSIGN(SharedPreferenceDeserializer);
   Maybe<base::SharedMemoryHandle> mPrefsHandle;
   Maybe<FileDescriptor> mPrefMapHandle;
   Maybe<size_t> mPrefsLen;
   Maybe<size_t> mPrefMapSize;
+  base::SharedMemory mShmem;
 };
 
 #ifdef ANDROID
 // Android doesn't use -prefsHandle or -prefMapHandle. It gets those FDs
 // another way.
 void SetPrefsFd(int aFd);
 void SetPrefMapFd(int aFd);
 #endif
--- a/ipc/glue/ProcessUtils_common.cpp
+++ b/ipc/glue/ProcessUtils_common.cpp
@@ -134,26 +134,25 @@ bool SharedPreferenceDeserializer::Deser
     return false;
   }
 
   // Init the shared-memory base preference mapping first, so that only changed
   // preferences wind up in heap memory.
   Preferences::InitSnapshot(mPrefMapHandle.ref(), *mPrefMapSize);
 
   // Set up early prefs from the shared memory.
-  base::SharedMemory shm;
-  if (!shm.SetHandle(*mPrefsHandle, /* read_only */ true)) {
+  if (!mShmem.SetHandle(*mPrefsHandle, /* read_only */ true)) {
     NS_ERROR("failed to open shared memory in the child");
     return false;
   }
-  if (!shm.Map(*mPrefsLen)) {
+  if (!mShmem.Map(*mPrefsLen)) {
     NS_ERROR("failed to map shared memory in the child");
     return false;
   }
-  Preferences::DeserializePreferences(static_cast<char*>(shm.memory()),
+  Preferences::DeserializePreferences(static_cast<char*>(mShmem.memory()),
                                       *mPrefsLen);
 
   return true;
 }
 
 const base::SharedMemoryHandle& SharedPreferenceDeserializer::GetPrefsHandle()
     const {
   MOZ_ASSERT(mPrefsHandle.isSome());
@@ -163,9 +162,9 @@ const base::SharedMemoryHandle& SharedPr
 
 const FileDescriptor& SharedPreferenceDeserializer::GetPrefMapHandle() const {
   MOZ_ASSERT(mPrefMapHandle.isSome());
 
   return mPrefMapHandle.ref();
 }
 
 }  // namespace ipc
-}  // namespace mozilla
\ No newline at end of file
+}  // namespace mozilla