Fix for issue 304: symupload needs to support timeout specifications(wininet can timeout when sending large symbol files).

R=doshimun
W=nealsid



git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@319 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
nealsid 2009-03-20 19:02:12 +00:00
parent 2ad976ef0b
commit 3366749ee7
4 changed files with 49 additions and 8 deletions

View file

@ -69,7 +69,7 @@ ReportResult CrashReportSender::SendCrashReport(
int http_response = 0;
bool result = HTTPUpload::SendRequest(
url, parameters, dump_file_name, L"upload_file_minidump", report_code,
url, parameters, dump_file_name, L"upload_file_minidump", NULL, report_code,
&http_response);
if (result) {

View file

@ -66,12 +66,13 @@ bool HTTPUpload::SendRequest(const wstring &url,
const map<wstring, wstring> &parameters,
const wstring &upload_file,
const wstring &file_part_name,
int *timeout,
wstring *response_body,
int *response_code) {
if (response_code) {
*response_code = 0;
}
// TODO(bryner): support non-ASCII parameter names
if (!CheckParameters(parameters)) {
return false;
@ -146,6 +147,22 @@ bool HTTPUpload::SendRequest(const wstring &url,
return false;
}
if (timeout) {
if (!InternetSetOption(request.get(),
INTERNET_OPTION_SEND_TIMEOUT,
timeout,
sizeof(timeout))) {
fwprintf(stderr, L"Could not unset send timeout, continuing...\n");
}
if (!InternetSetOption(request.get(),
INTERNET_OPTION_RECEIVE_TIMEOUT,
timeout,
sizeof(timeout))) {
fwprintf(stderr, L"Could not unset receive timeout, continuing...\n");
}
}
if (!HttpSendRequest(request.get(), NULL, 0,
const_cast<char *>(request_body.data()),
static_cast<DWORD>(request_body.size()))) {

View file

@ -69,6 +69,7 @@ class HTTPUpload {
const map<wstring, wstring> &parameters,
const wstring &upload_file,
const wstring &file_part_name,
int *timeout,
wstring *response_body,
int *response_code);

View file

@ -131,12 +131,13 @@ static bool DumpSymbolsToTempFile(const wchar_t *file,
FILE *temp_file = NULL;
#if _MSC_VER >= 1400 // MSVC 2005/8
if (_wfopen_s(&temp_file, temp_filename, L"w") != 0) {
if (_wfopen_s(&temp_file, temp_filename, L"w") != 0)
#else // _MSC_VER >= 1400
// _wfopen_s was introduced in MSVC8. Use _wfopen for earlier environments.
// Don't use it with MSVC8 and later, because it's deprecated.
if (!(temp_file = _wfopen(temp_filename, L"w"))) {
if (!(temp_file = _wfopen(temp_filename, L"w")))
#endif // _MSC_VER >= 1400
{
return false;
}
@ -152,12 +153,33 @@ static bool DumpSymbolsToTempFile(const wchar_t *file,
return writer.GetModuleInfo(pdb_info);
}
void printUsageAndExit() {
wprintf(L"Usage: symupload [--timeout NN] <file.exe|file.dll> <symbol upload URL>\n\n");
wprintf(L"Timeout is in milliseconds, or can be 0 to be unlimited\n\n");
wprintf(L"Example:\n\n\tsymupload.exe --timeout 0 chrome.dll http://no.free.symbol.server.for.you\n");
exit(0);
}
int wmain(int argc, wchar_t *argv[]) {
if (argc < 3) {
wprintf(L"Usage: %s <file.exe|file.dll> <symbol upload URL>\n", argv[0]);
return 0;
if ((argc != 3) &&
(argc != 5)) {
printUsageAndExit();
}
const wchar_t *module, *url;
int timeout = -1;
if (argc == 3) {
module = argv[1];
url = argv[2];
} else {
// check for timeout flag
if (!wcscmp(L"--timeout", argv[1])) {
timeout = _wtoi(argv[2]);
module = argv[3];
url = argv[4];
} else {
printUsageAndExit();
}
}
const wchar_t *module = argv[1], *url = argv[2];
wstring symbol_file;
PDBModuleInfo pdb_info;
@ -186,6 +208,7 @@ int wmain(int argc, wchar_t *argv[]) {
bool success = HTTPUpload::SendRequest(url, parameters,
symbol_file, L"symbol_file",
timeout == -1 ? NULL : &timeout,
NULL, NULL);
_wunlink(symbol_file.c_str());