From d55a5f3dcaf515dc07f24bf4d9a83bddc8b82354 Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Thu, 27 Jan 2022 16:52:13 -0800 Subject: [PATCH] Make symupload v2 api respect --timeout flag Change-Id: I763f45aa395a56e9c3285544e7755a1e5a85dbe4 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3422007 Reviewed-by: Nelson Billing Reviewed-by: Joshua Peraza --- src/common/windows/symbol_collector_client.cc | 9 ++++++--- src/common/windows/symbol_collector_client.h | 3 +++ src/tools/windows/symupload/symupload.cc | 14 +++++++------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/common/windows/symbol_collector_client.cc b/src/common/windows/symbol_collector_client.cc index 30c663ed..6e871bf0 100644 --- a/src/common/windows/symbol_collector_client.cc +++ b/src/common/windows/symbol_collector_client.cc @@ -12,6 +12,7 @@ namespace google_breakpad { bool SymbolCollectorClient::CreateUploadUrl( wstring& api_url, wstring& api_key, + int* timeout_ms, UploadUrlResponse *uploadUrlResponse) { wstring url = api_url + L"/v1/uploads:create" @@ -23,7 +24,7 @@ namespace google_breakpad { url, L"", L"", - NULL, + timeout_ms, &response, &response_code)) { wprintf(L"Failed to create upload url.\n"); @@ -66,6 +67,7 @@ namespace google_breakpad { CompleteUploadResult SymbolCollectorClient::CompleteUpload( wstring& api_url, wstring& api_key, + int* timeout_ms, const wstring& upload_key, const wstring& debug_file, const wstring& debug_id) { @@ -84,7 +86,7 @@ namespace google_breakpad { url, body, L"application/json", - NULL, + timeout_ms, &response, &response_code)) { wprintf(L"Failed to complete upload.\n"); @@ -116,6 +118,7 @@ namespace google_breakpad { SymbolStatus SymbolCollectorClient::CheckSymbolStatus( wstring& api_url, wstring& api_key, + int* timeout_ms, const wstring& debug_file, const wstring& debug_id) { wstring response; @@ -126,7 +129,7 @@ namespace google_breakpad { if (!HTTPUpload::SendGetRequest( url, - NULL, + timeout_ms, &response, &response_code)) { wprintf(L"Failed to check symbol status.\n"); diff --git a/src/common/windows/symbol_collector_client.h b/src/common/windows/symbol_collector_client.h index 30e0cb32..4a85c052 100644 --- a/src/common/windows/symbol_collector_client.h +++ b/src/common/windows/symbol_collector_client.h @@ -64,6 +64,7 @@ namespace google_breakpad { static bool CreateUploadUrl( wstring& api_url, wstring& api_key, + int* timeout_ms, UploadUrlResponse *uploadUrlResponse); // Notify the API that symbol file upload is finished and its contents @@ -71,6 +72,7 @@ namespace google_breakpad { static CompleteUploadResult CompleteUpload( wstring& api_url, wstring& api_key, + int* timeout_ms, const wstring& upload_key, const wstring& debug_file, const wstring& debug_id); @@ -80,6 +82,7 @@ namespace google_breakpad { static SymbolStatus CheckSymbolStatus( wstring& api_url, wstring& api_key, + int* timeout_ms, const wstring& debug_file, const wstring& debug_id); }; diff --git a/src/tools/windows/symupload/symupload.cc b/src/tools/windows/symupload/symupload.cc index c774b0e7..3a26ca89 100644 --- a/src/tools/windows/symupload/symupload.cc +++ b/src/tools/windows/symupload/symupload.cc @@ -163,6 +163,7 @@ static bool DumpSymbolsToTempFile(const wchar_t* file, static bool DoSymUploadV2( const wchar_t* api_url, const wchar_t* api_key, + int* timeout_ms, const wstring& debug_file, const wstring& debug_id, const wstring& symbol_file, @@ -174,6 +175,7 @@ static bool DoSymUploadV2( SymbolStatus symbolStatus = SymbolCollectorClient::CheckSymbolStatus( url, key, + timeout_ms, debug_file, debug_id); if (symbolStatus == SymbolStatus::Found) { @@ -191,6 +193,7 @@ static bool DoSymUploadV2( if (!SymbolCollectorClient::CreateUploadUrl( url, key, + timeout_ms, &uploadUrlResponse)) { wprintf(L"Failed to create upload URL.\n"); return false; @@ -203,7 +206,7 @@ static bool DoSymUploadV2( bool success = HTTPUpload::SendPutRequest( signed_url, symbol_file, - /* timeout = */ NULL, + timeout_ms, &response, &response_code); if (!success) { @@ -228,6 +231,7 @@ static bool DoSymUploadV2( SymbolCollectorClient::CompleteUpload( url, key, + timeout_ms, upload_key, debug_file, debug_id); @@ -339,12 +343,8 @@ int wmain(int argc, wchar_t* argv[]) { api_key = argv[currentarg++]; success = DoSymUploadV2( - api_url, - api_key, - pdb_info.debug_file, - pdb_info.debug_identifier, - symbol_file, - force); + api_url, api_key, timeout == -1 ? nullptr : &timeout, + pdb_info.debug_file, pdb_info.debug_identifier, symbol_file, force); } else { printUsageAndExit(); }