diff --git a/src/client/windows/sender/crash_report_sender.cc b/src/client/windows/sender/crash_report_sender.cc index 7672acfd..3d16ef21 100644 --- a/src/client/windows/sender/crash_report_sender.cc +++ b/src/client/windows/sender/crash_report_sender.cc @@ -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) { diff --git a/src/common/windows/http_upload.cc b/src/common/windows/http_upload.cc index 2f9ffa92..686c2ab5 100644 --- a/src/common/windows/http_upload.cc +++ b/src/common/windows/http_upload.cc @@ -66,12 +66,13 @@ bool HTTPUpload::SendRequest(const wstring &url, const map ¶meters, 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(request_body.data()), static_cast(request_body.size()))) { diff --git a/src/common/windows/http_upload.h b/src/common/windows/http_upload.h index a1ba7ae1..f7c69f16 100644 --- a/src/common/windows/http_upload.h +++ b/src/common/windows/http_upload.h @@ -69,6 +69,7 @@ class HTTPUpload { const map ¶meters, const wstring &upload_file, const wstring &file_part_name, + int *timeout, wstring *response_body, int *response_code); diff --git a/src/tools/windows/symupload/symupload.cc b/src/tools/windows/symupload/symupload.cc index e2ec640e..b858a63d 100644 --- a/src/tools/windows/symupload/symupload.cc +++ b/src/tools/windows/symupload/symupload.cc @@ -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] \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 \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());