From 8a1b9b7c3ec3ab481e331dc1b29f644cabc4bf16 Mon Sep 17 00:00:00 2001 From: JoshuaMoelans <60878493+JoshuaMoelans@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:58:55 +0100 Subject: [PATCH] enable retry for non-iOS builds --- handler/crash_report_upload_thread.cc | 18 +----------------- handler/crash_report_upload_thread.h | 6 +----- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/handler/crash_report_upload_thread.cc b/handler/crash_report_upload_thread.cc index 991013a26..c41d2c20d 100644 --- a/handler/crash_report_upload_thread.cc +++ b/handler/crash_report_upload_thread.cc @@ -56,13 +56,11 @@ namespace { // The number of seconds to wait between checking for pending reports. const int kRetryWorkIntervalSeconds = 15 * 60; -#if BUILDFLAG(IS_IOS) // The number of times to attempt to upload a pending report, repeated on // failure. Attempts will happen once per launch, once per call to // ReportPending(), and, if Options.watch_pending_reports is true, once every -// kRetryWorkIntervalSeconds. Currently iOS only. +// kRetryWorkIntervalSeconds. const int kRetryAttempts = 5; -#endif // Wraps a reference to a no-args function (which can be empty). When this // object goes out of scope, invokes the function if it is non-empty. @@ -211,10 +209,8 @@ void CrashReportUploadThread::ProcessPendingReport( if (ShouldRateLimitUpload(report)) return; -#if BUILDFLAG(IS_IOS) if (ShouldRateLimitRetry(report)) return; -#endif // BUILDFLAG(IS_IOS) std::unique_ptr upload_report; CrashReportDatabase::OperationStatus status = @@ -256,7 +252,6 @@ void CrashReportUploadThread::ProcessPendingReport( report.uuid, Metrics::CrashSkippedReason::kPrepareForUploadFailed); break; case UploadResult::kRetry: -#if BUILDFLAG(IS_IOS) if (upload_report->upload_attempts > kRetryAttempts) { upload_report.reset(); database_->SkipReportUpload(report.uuid, @@ -268,15 +263,6 @@ void CrashReportUploadThread::ProcessPendingReport( time(nullptr) + (1 << upload_report->upload_attempts) * kRetryWorkIntervalSeconds; } -#else - upload_report.reset(); - - // TODO(mark): Deal with retries properly: don’t call SkipReportUplaod() - // if the result was kRetry and the report hasn’t already been retried - // too many times. - database_->SkipReportUpload(report.uuid, - Metrics::CrashSkippedReason::kUploadFailed); -#endif break; } } @@ -417,7 +403,6 @@ bool CrashReportUploadThread::ShouldRateLimitUpload( return false; } -#if BUILDFLAG(IS_IOS) bool CrashReportUploadThread::ShouldRateLimitRetry( const CrashReportDatabase::Report& report) { if (retry_uuid_time_map_.find(report.uuid) != retry_uuid_time_map_.end()) { @@ -430,6 +415,5 @@ bool CrashReportUploadThread::ShouldRateLimitRetry( } return false; } -#endif } // namespace crashpad diff --git a/handler/crash_report_upload_thread.h b/handler/crash_report_upload_thread.h index 6bde3835b..80700d2c6 100644 --- a/handler/crash_report_upload_thread.h +++ b/handler/crash_report_upload_thread.h @@ -208,7 +208,6 @@ class CrashReportUploadThread : public WorkerThread::Delegate, //! upload attempts to be retried. bool ShouldRateLimitUpload(const CrashReportDatabase::Report& report); -#if BUILDFLAG(IS_IOS) //! \brief Rate-limit report retries. //! //! \param[in] report The crash report to process. @@ -217,12 +216,11 @@ class CrashReportUploadThread : public WorkerThread::Delegate, //! rate limit in ShouldRateLimitUpload). When a report upload ends in a retry //! state, an in-memory only timestamp is stored in |retry_uuid_time_map_| //! with the next possible retry time. This timestamp is a backoff from the - //! main thread work interval, doubling on each attemt. Because this is only + //! main thread work interval, doubling on each attempt. Because this is only //! stored in memory, on restart reports in the retry state will always be //! tried once, and then fall back into the next backoff. This continues until //! kRetryAttempts is reached. bool ShouldRateLimitRetry(const CrashReportDatabase::Report& report); -#endif const Options options_; const ProcessPendingReportsObservationCallback callback_; @@ -230,10 +228,8 @@ class CrashReportUploadThread : public WorkerThread::Delegate, const std::string http_proxy_; WorkerThread thread_; ThreadSafeVector known_pending_report_uuids_; -#if BUILDFLAG(IS_IOS) // This is not thread-safe, and only used by the worker thread. std::map retry_uuid_time_map_; -#endif CrashReportDatabase* database_; // weak };