Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Side by Side Diff: base/shared_memory_posix.cc

Issue 1937008: Valid FDs are >= 0 (> -1), not >= -1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/shared_memory.h" 5 #include "base/shared_memory.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/mman.h> 9 #include <sys/mman.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 munmap(memory_, max_size_); 257 munmap(memory_, max_size_);
258 memory_ = NULL; 258 memory_ = NULL;
259 max_size_ = 0; 259 max_size_ = 0;
260 return true; 260 return true;
261 } 261 }
262 262
263 bool SharedMemory::ShareToProcessCommon(ProcessHandle process, 263 bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
264 SharedMemoryHandle *new_handle, 264 SharedMemoryHandle *new_handle,
265 bool close_self) { 265 bool close_self) {
266 const int new_fd = dup(mapped_file_); 266 const int new_fd = dup(mapped_file_);
267 DCHECK(new_fd >= -1); 267 DCHECK(new_fd >= 0);
268 new_handle->fd = new_fd; 268 new_handle->fd = new_fd;
269 new_handle->auto_close = true; 269 new_handle->auto_close = true;
270 270
271 if (close_self) 271 if (close_self)
272 Close(); 272 Close();
273 273
274 return true; 274 return true;
275 } 275 }
276 276
277 277
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 309
310 void SharedMemory::Unlock() { 310 void SharedMemory::Unlock() {
311 LockOrUnlockCommon(F_ULOCK); 311 LockOrUnlockCommon(F_ULOCK);
312 } 312 }
313 313
314 SharedMemoryHandle SharedMemory::handle() const { 314 SharedMemoryHandle SharedMemory::handle() const {
315 return FileDescriptor(mapped_file_, false); 315 return FileDescriptor(mapped_file_, false);
316 } 316 }
317 317
318 } // namespace base 318 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698