Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1027)

Unified Diff: libcurl_http_fetcher.cc

Issue 5009009: AU: Fix potential issues with premature destruction of HTTP fetchers. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: review comments Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « libcurl_http_fetcher.h ('k') | mock_http_fetcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libcurl_http_fetcher.cc
diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc
index d5358bd252118b90efa4fd8219192c51d2cf77ca..b65d6b1e2e71aa73abd72e1d4b8b300124a61912 100644
--- a/libcurl_http_fetcher.cc
+++ b/libcurl_http_fetcher.cc
@@ -28,6 +28,8 @@ const char kCACertificatesPath[] = "/usr/share/update_engine/ca-certificates";
} // namespace {}
LibcurlHttpFetcher::~LibcurlHttpFetcher() {
+ LOG_IF(ERROR, transfer_in_progress_)
+ << "Destroying the fetcher while a transfer is in progress.";
CleanUp();
}
@@ -135,11 +137,20 @@ void LibcurlHttpFetcher::BeginTransfer(const std::string& url) {
CurlPerformOnce();
}
+void LibcurlHttpFetcher::ForceTransferTermination() {
+ CleanUp();
+ if (delegate_) {
+ // Note that after the callback returns this object may be destroyed.
+ delegate_->TransferTerminated(this);
+ }
+}
+
void LibcurlHttpFetcher::TerminateTransfer() {
- if (in_write_callback_)
+ if (in_write_callback_) {
terminate_requested_ = true;
- else
- CleanUp();
+ } else {
+ ForceTransferTermination();
+ }
}
void LibcurlHttpFetcher::CurlPerformOnce() {
@@ -152,7 +163,7 @@ void LibcurlHttpFetcher::CurlPerformOnce() {
while (CURLM_CALL_MULTI_PERFORM == retcode) {
retcode = curl_multi_perform(curl_multi_handle_, &running_handles);
if (terminate_requested_) {
- CleanUp();
+ ForceTransferTermination();
return;
}
}
« no previous file with comments | « libcurl_http_fetcher.h ('k') | mock_http_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698