Bug 1479960 - Remove SHM_ANON support. r=froydnj
authorJed Davis <jld@mozilla.com>
Wed, 14 Aug 2019 22:48:20 +0000
changeset 488042 16d99c5a8a550366c7785edaeadf67c14d7151f1
parent 488041 9b390150ec32771f276b47186e7467bc68d6fb5c
child 488043 f814f58d43d66df993d9d9d492ec39c1417b1a3d
push id36434
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:44:30 +0000
treeherdermozilla-central@144fbfb409b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1479960
milestone70.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 1479960 - Remove SHM_ANON support. r=froydnj FreeBSD's SHM_ANON is useful for the usual case of shared memory, but it doesn't support freezing. It could be re-added later, but for now it's simplest to remove it (and use named shm instead) while refactoring. Depends on D26738 Differential Revision: https://phabricator.services.mozilla.com/D26739
ipc/chromium/src/base/shared_memory_posix.cc
--- a/ipc/chromium/src/base/shared_memory_posix.cc
+++ b/ipc/chromium/src/base/shared_memory_posix.cc
@@ -56,17 +56,17 @@ bool SharedMemory::IsHandleValid(const S
   return handle.fd >= 0;
 }
 
 // static
 SharedMemoryHandle SharedMemory::NULLHandle() { return SharedMemoryHandle(); }
 
 // static
 bool SharedMemory::AppendPosixShmPrefix(std::string* str, pid_t pid) {
-#if defined(ANDROID) || defined(SHM_ANON)
+#if defined(ANDROID)
   return false;
 #else
   *str += '/';
 #  ifdef OS_LINUX
   // The Snap package environment doesn't provide a private /dev/shm
   // (it's used for communication with services like PulseAudio);
   // instead AppArmor is used to restrict access to it.  Anything with
   // this prefix is allowed:
@@ -82,17 +82,17 @@ bool SharedMemory::AppendPosixShmPrefix(
   if (kSnap) {
     StringAppendF(str, "snap.%s.", kSnap);
   }
 #  endif  // OS_LINUX
   // Hopefully the "implementation defined" name length limit is long
   // enough for this.
   StringAppendF(str, "org.mozilla.ipc.%d.", static_cast<int>(pid));
   return true;
-#endif    // !ANDROID && !SHM_ANON
+#endif    // !ANDROID
 }
 
 bool SharedMemory::Create(size_t size) {
   read_only_ = false;
 
   DCHECK(size > 0);
   DCHECK(mapped_file_ == -1);
 
@@ -107,20 +107,16 @@ bool SharedMemory::Create(size_t size) {
     return false;
   }
   if (ioctl(fd, ASHMEM_SET_SIZE, size) != 0) {
     CHROMIUM_LOG(WARNING) << "failed to set shm size: " << strerror(errno);
     close(fd);
     return false;
   }
   needs_truncate = false;
-#elif defined(SHM_ANON)
-  // FreeBSD (or any other Unix that might decide to implement this
-  // nice, simple API):
-  fd = shm_open(SHM_ANON, O_RDWR, 0600);
 #else
   // Generic Unix: shm_open + shm_unlink
   do {
     // The names don't need to be unique, but it saves time if they
     // usually are.
     static mozilla::Atomic<size_t> sNameCounter;
     std::string name;
     CHECK(AppendPosixShmPrefix(&name, getpid()));