win: Only retry in UseHandler() loop on ERROR_PIPE_BUSY

This is better because now end_to_end_test.py fails immediately with

[1180:9020:20151106,145204.830:ERROR registration_protocol_win.cc:39] CreateFile: The system cannot find the file specified.  (0x2)

R=mark@chromium.org
BUG=crashpad:75

Review URL: https://codereview.chromium.org/1409693011 .
This commit is contained in:
Scott Graham 2015-11-06 15:54:48 -08:00
Родитель 9e4cd8f07b
Коммит ff274507dc
2 изменённых файлов: 25 добавлений и 8 удалений

Просмотреть файл

@ -21,6 +21,7 @@ import re
import subprocess
import sys
import tempfile
import time
g_temp_dirs = []
@ -101,6 +102,14 @@ def GetDumpFromProgram(out_dir, pipe_name, executable_name):
'--database=' + test_database
])
# Wait until the server is ready.
printed = False
while not os.path.exists(pipe_name):
if not printed:
print 'Waiting for crashpad_handler to be ready...'
printed = True
time.sleep(0.1)
subprocess.call([os.path.join(out_dir, executable_name), pipe_name])
else:
subprocess.call([os.path.join(out_dir, executable_name),

Просмотреть файл

@ -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