Chromium Code Reviews| 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..42d9b652ec42ad4bebd30067f7cb3de0c01a85f1 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) { |
|
Mark Mentovai
2015/11/06 23:32:35
We want ++tries to be equivalent to the previous b
scottmg
2015/11/06 23:53:40
Done.
|
| + 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"; |
| @@ -64,9 +74,6 @@ bool SendToCrashHandlerServer(const base::string16& pipe_name, |
| } |
| return true; |
| } |
| - |
| - LOG(ERROR) << "failed to connect after retrying"; |
| - return false; |
| } |
| } // namespace crashpad |