diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-23 12:38:08 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-23 12:38:08 +0000 |
commit | 4530149ff00f8970e3b06f6580c109ee74753694 (patch) | |
tree | 7541528bc1add772963ad8b889f9dd7dd6eb2b71 /base/file_util_posix.cc | |
parent | b2edf0a95849836ab55c65a3fe0ed89a0e4616ea (diff) | |
download | chromium_src-4530149ff00f8970e3b06f6580c109ee74753694.zip chromium_src-4530149ff00f8970e3b06f6580c109ee74753694.tar.gz chromium_src-4530149ff00f8970e3b06f6580c109ee74753694.tar.bz2 |
Protect RandUint64 against EINTR.
Review URL: http://codereview.chromium.org/77022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14297 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_posix.cc')
-rw-r--r-- | base/file_util_posix.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index 6a36c62..f571c5e 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -316,6 +316,18 @@ bool GetFileCreationLocalTime(const std::string& filename, } #endif +bool ReadFromFD(int fd, char* buffer, size_t bytes) { + size_t total_read = 0; + while (total_read < bytes) { + ssize_t bytes_read = read(fd, buffer + total_read, bytes - total_read); + if (bytes_read > 0) + total_read += bytes_read; + else if (errno != EINTR || bytes_read == 0) + break; + } + return total_read == bytes; +} + // Creates and opens a temporary file in |directory|, returning the // file descriptor. |path| is set to the temporary file path. // Note TODO(erikkay) comment in header for BlahFileName() calls; the |