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

Unified Diff: util/file/file_io_win.cc

Issue 880763002: Reorganize Multiprocess and implement for Windows (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fixes 2 Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « snapshot/mac/process_reader_test.cc ('k') | util/mach/exception_ports_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/file/file_io_win.cc
diff --git a/util/file/file_io_win.cc b/util/file/file_io_win.cc
index 861f15acc64e2243c2b5d024bc68f7b947ff15e4..adbe7a99efaa15498877220d67c38c40860f4170 100644
--- a/util/file/file_io_win.cc
+++ b/util/file/file_io_win.cc
@@ -44,10 +44,16 @@ ssize_t ReadFile(FileHandle file, void* buffer, size_t size) {
while (size_dword > 0) {
DWORD bytes_read;
BOOL success = ::ReadFile(file, buffer_c, size_dword, &bytes_read, nullptr);
- if (!success && GetLastError() != ERROR_MORE_DATA) {
- return -1;
- } else if (success && bytes_read == 0 &&
- GetFileType(file) != FILE_TYPE_PIPE) {
+ if (!success) {
+ if (GetLastError() == ERROR_BROKEN_PIPE) {
+ // When reading a pipe and the write handle has been closed, ReadFile
+ // fails with ERROR_BROKEN_PIPE, but only once all pending data has been
+ // read.
+ break;
+ } else if (GetLastError() != ERROR_MORE_DATA) {
+ return -1;
+ }
+ } else if (bytes_read == 0 && GetFileType(file) != FILE_TYPE_PIPE) {
// Zero bytes read for a file indicates reaching EOF. Zero bytes read from
// a pipe indicates only that there was a zero byte WriteFile issued on
// the other end, so continue reading.
« no previous file with comments | « snapshot/mac/process_reader_test.cc ('k') | util/mach/exception_ports_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698