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

Side by Side Diff: base/files/scoped_file.cc

Issue 2642483002: Relax ScopedFD close() error checking (Closed)
Patch Set: add back alias and todo Created 3 years, 11 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
« 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/files/scoped_file.h" 5 #include "base/files/scoped_file.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #if defined(OS_POSIX) 10 #if defined(OS_POSIX)
(...skipping 19 matching lines...) Expand all
30 // It's especially problematic on Linux with the setuid sandbox, where 30 // It's especially problematic on Linux with the setuid sandbox, where
31 // a single open directory would bypass the entire security model. 31 // a single open directory would bypass the entire security model.
32 int ret = IGNORE_EINTR(close(fd)); 32 int ret = IGNORE_EINTR(close(fd));
33 33
34 // TODO(davidben): Remove this once it's been determined whether 34 // TODO(davidben): Remove this once it's been determined whether
35 // https://crbug.com/603354 is caused by EBADF or a network filesystem 35 // https://crbug.com/603354 is caused by EBADF or a network filesystem
36 // returning some other error. 36 // returning some other error.
37 int close_errno = errno; 37 int close_errno = errno;
38 base::debug::Alias(&close_errno); 38 base::debug::Alias(&close_errno);
39 39
40 #if defined(OS_LINUX)
41 // NB: Some file descriptors can return errors from close() e.g. network
42 // filesystems such as NFS and Linux input devices. On Linux, errors from
43 // close other than EBADF do not indicate failure to actually close the fd.
44 if (ret != 0 && errno != EBADF)
45 ret = 0;
46 #endif
47
40 PCHECK(0 == ret); 48 PCHECK(0 == ret);
41 } 49 }
42 50
43 #endif // OS_POSIX 51 #endif // OS_POSIX
44 52
45 } // namespace internal 53 } // namespace internal
46 } // namespace base 54 } // 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