View | Details | Raw Unified | Return to bug 222356 | Differences between
and this patch

Collapse All | Expand All

(-)ipc/chromium/src/base/shared_memory.h (-2 lines)
Lines 114-120 Link Here
114
  // are technically only unique to a single filesystem. However, we always
114
  // are technically only unique to a single filesystem. However, we always
115
  // allocate shared memory backing files from the same directory, so will end
115
  // allocate shared memory backing files from the same directory, so will end
116
  // up on the same filesystem.
116
  // up on the same filesystem.
117
  SharedMemoryId id() const { return inode_; }
118
#endif
117
#endif
119
118
120
  // Closes the open shared memory segment.
119
  // Closes the open shared memory segment.
Lines 174-180 Link Here
174
  HANDLE             mapped_file_;
173
  HANDLE             mapped_file_;
175
#elif defined(OS_POSIX)
174
#elif defined(OS_POSIX)
176
  int                mapped_file_;
175
  int                mapped_file_;
177
  ino_t              inode_;
178
#endif
176
#endif
179
  void*              memory_;
177
  void*              memory_;
180
  bool               read_only_;
178
  bool               read_only_;
(-)ipc/chromium/src/base/shared_memory_posix.cc (-11 / +3 lines)
Lines 22-28 Link Here
22
22
23
SharedMemory::SharedMemory()
23
SharedMemory::SharedMemory()
24
    : mapped_file_(-1),
24
    : mapped_file_(-1),
25
      inode_(0),
26
      memory_(NULL),
25
      memory_(NULL),
27
      read_only_(false),
26
      read_only_(false),
28
      max_size_(0) {
27
      max_size_(0) {
Lines 41-47 Link Here
41
  }
40
  }
42
41
43
  mapped_file_ = handle.fd;
42
  mapped_file_ = handle.fd;
44
  inode_ = st.st_ino;
45
  read_only_ = read_only;
43
  read_only_ = read_only;
46
  return true;
44
  return true;
47
}
45
}
Lines 155-167 Link Here
155
    // It doesn't make sense to have a read-only private piece of shmem
153
    // It doesn't make sense to have a read-only private piece of shmem
156
    DCHECK(posix_flags & (O_RDWR | O_WRONLY));
154
    DCHECK(posix_flags & (O_RDWR | O_WRONLY));
157
155
158
    FilePath path;
156
    int fd = shm_open(SHM_ANON, posix_flags, 0600);
159
    fp = file_util::CreateAndOpenTemporaryShmemFile(&path);
157
    fp = fdopen(fd, "a+");
160
161
    // Deleting the file prevents anyone else from mapping it in
162
    // (making it private), and prevents the need for cleanup (once
163
    // the last fd is closed, it is truly freed).
164
    file_util::Delete(path);
165
  } else {
158
  } else {
166
    std::wstring mem_filename;
159
    std::wstring mem_filename;
167
    if (FilenameForMemoryName(name, &mem_filename) == false)
160
    if (FilenameForMemoryName(name, &mem_filename) == false)
Lines 214-220 Link Here
214
  struct stat st;
207
  struct stat st;
215
  if (fstat(mapped_file_, &st))
208
  if (fstat(mapped_file_, &st))
216
    NOTREACHED();
209
    NOTREACHED();
217
  inode_ = st.st_ino;
218
210
219
  return true;
211
  return true;
220
}
212
}
Lines 224-230 Link Here
224
    return false;
216
    return false;
225
217
226
  memory_ = mmap(NULL, bytes, PROT_READ | (read_only_ ? 0 : PROT_WRITE),
218
  memory_ = mmap(NULL, bytes, PROT_READ | (read_only_ ? 0 : PROT_WRITE),
227
                 MAP_SHARED, mapped_file_, 0);
219
                 MAP_SHARED | MAP_NOSYNC, mapped_file_, 0);
228
220
229
  if (memory_)
221
  if (memory_)
230
    max_size_ = bytes;
222
    max_size_ = bytes;

Return to bug 222356