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

Unified Diff: util/win/registration_protocol_win.cc

Issue 1409693011: win: Only retry in UseHandler() loop on ERROR_PIPE_BUSY (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fixes Created 5 years, 1 month 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/win/end_to_end_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/win/registration_protocol_win.cc
diff --git a/util/win/registration_protocol_win.cc b/util/win/registration_protocol_win.cc
index 3e0fdf213985a4bc81ae295bd3377140463045da..38b1b45195a6b86f2353da09e1da04e8f5f9252d 100644
--- a/util/win/registration_protocol_win.cc
+++ b/util/win/registration_protocol_win.cc
@@ -24,8 +24,8 @@ namespace crashpad {
bool SendToCrashHandlerServer(const base::string16& pipe_name,
const crashpad::ClientToServerMessage& message,
crashpad::ServerToClientMessage* response) {
- int tries = 5;
- while (tries > 0) {
+ int tries = 0;
+ for (;;) {
ScopedFileHANDLE pipe(
CreateFile(pipe_name.c_str(),
GENERIC_READ | GENERIC_WRITE,
@@ -35,10 +35,20 @@ bool SendToCrashHandlerServer(const base::string16& pipe_name,
SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION,
nullptr));
if (!pipe.is_valid()) {
- Sleep(10);
- --tries;
+ if (++tries == 5 || GetLastError() != ERROR_PIPE_BUSY) {
+ PLOG(ERROR) << "CreateFile";
+ return false;
+ }
+
+ if (!WaitNamedPipe(pipe_name.c_str(), 1000) &&
+ GetLastError() != ERROR_SEM_TIMEOUT) {
+ PLOG(ERROR) << "WaitNamedPipe";
+ return false;
+ }
+
continue;
}
+
DWORD mode = PIPE_READMODE_MESSAGE;
if (!SetNamedPipeHandleState(pipe.get(), &mode, nullptr, nullptr)) {
PLOG(ERROR) << "SetNamedPipeHandleState";
@@ -55,7 +65,8 @@ bool SendToCrashHandlerServer(const base::string16& pipe_name,
&bytes_read,
nullptr);
if (!result) {
- PLOG(ERROR) << "TransactNamedPipe";
+ LOG(ERROR) << "TransactNamedPipe: expected " << sizeof(*response)
+ << ", observed " << bytes_read;
return false;
}
if (bytes_read != sizeof(*response)) {
@@ -64,9 +75,6 @@ bool SendToCrashHandlerServer(const base::string16& pipe_name,
}
return true;
}
-
- LOG(ERROR) << "failed to connect after retrying";
- return false;
}
} // namespace crashpad
« no previous file with comments | « snapshot/win/end_to_end_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698