Cleanup the RetryTimeoutCallback().
When canceling a request or destroying the LibcurlHttpFetcher, a
RetryTimeoutCallback callback could be leaked if the fetcher was
waiting on a network retry.
This patch keeps track of the retry callback and cancels it on CleanUp,
making sure the callback is not leaked.
Bug: 34178297
Test: Added unittest to trigger this case.
Change-Id: I7016641a7f31429933779e55c77cbabb6289c3dd
diff --git a/libcurl_http_fetcher.h b/libcurl_http_fetcher.h
index 1541ea4..5b16811 100644
--- a/libcurl_http_fetcher.h
+++ b/libcurl_http_fetcher.h
@@ -233,6 +233,9 @@
// Seconds to wait before retrying a resume.
int retry_seconds_{20};
+ // When waiting for a retry, the task id of the retry callback.
+ brillo::MessageLoop::TaskId retry_task_id_{brillo::MessageLoop::kTaskIdNull};
+
// Number of resumes due to no network (e.g., HTTP response code 0).
int no_network_retry_count_{0};
int no_network_max_retries_{0};