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

Side by Side Diff: libcurl_http_fetcher.cc

Issue 3035024: Increase HTTP request timeout to make dev server happy. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "update_engine/libcurl_http_fetcher.h" 5 #include "update_engine/libcurl_http_fetcher.h"
6 #include <algorithm> 6 #include <algorithm>
7 #include "chromeos/obsolete_logging.h" 7 #include "chromeos/obsolete_logging.h"
8 8
9 using std::max; 9 using std::max;
10 using std::make_pair; 10 using std::make_pair;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 CHECK_EQ(curl_easy_setopt(curl_handle_, 48 CHECK_EQ(curl_easy_setopt(curl_handle_,
49 CURLOPT_RESUME_FROM_LARGE, 49 CURLOPT_RESUME_FROM_LARGE,
50 bytes_downloaded_), CURLE_OK); 50 bytes_downloaded_), CURLE_OK);
51 } 51 }
52 52
53 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_WRITEDATA, this), CURLE_OK); 53 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_WRITEDATA, this), CURLE_OK);
54 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_WRITEFUNCTION, 54 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_WRITEFUNCTION,
55 StaticLibcurlWrite), CURLE_OK); 55 StaticLibcurlWrite), CURLE_OK);
56 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_URL, url_.c_str()), CURLE_OK); 56 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_URL, url_.c_str()), CURLE_OK);
57 57
58 // If the connection drops under 10 bytes/sec for 90 seconds, reconnect. 58 // If the connection drops under 10 bytes/sec for 3 minutes, reconnect.
59 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_LOW_SPEED_LIMIT, 10), 59 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_LOW_SPEED_LIMIT, 10),
60 CURLE_OK); 60 CURLE_OK);
61 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_LOW_SPEED_TIME, 90), 61 CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_LOW_SPEED_TIME, 3 * 60),
62 CURLE_OK); 62 CURLE_OK);
63 63
64 CHECK_EQ(curl_multi_add_handle(curl_multi_handle_, curl_handle_), CURLM_OK); 64 CHECK_EQ(curl_multi_add_handle(curl_multi_handle_, curl_handle_), CURLM_OK);
65 transfer_in_progress_ = true; 65 transfer_in_progress_ = true;
66 } 66 }
67 67
68 // Begins the transfer, which must not have already been started. 68 // Begins the transfer, which must not have already been started.
69 void LibcurlHttpFetcher::BeginTransfer(const std::string& url) { 69 void LibcurlHttpFetcher::BeginTransfer(const std::string& url) {
70 transfer_size_ = -1; 70 transfer_size_ = -1;
71 bytes_downloaded_ = 0; 71 bytes_downloaded_ = 0;
(...skipping 19 matching lines...) Expand all
91 } 91 }
92 if (0 == running_handles) { 92 if (0 == running_handles) {
93 long http_response_code = 0; 93 long http_response_code = 0;
94 if (curl_easy_getinfo(curl_handle_, 94 if (curl_easy_getinfo(curl_handle_,
95 CURLINFO_RESPONSE_CODE, 95 CURLINFO_RESPONSE_CODE,
96 &http_response_code) == CURLE_OK) { 96 &http_response_code) == CURLE_OK) {
97 LOG(INFO) << "HTTP response code: " << http_response_code; 97 LOG(INFO) << "HTTP response code: " << http_response_code;
98 } else { 98 } else {
99 LOG(ERROR) << "Unable to get http response code."; 99 LOG(ERROR) << "Unable to get http response code.";
100 } 100 }
101 101
102 // we're done! 102 // we're done!
103 CleanUp(); 103 CleanUp();
104 104
105 if ((transfer_size_ >= 0) && (bytes_downloaded_ < transfer_size_)) { 105 if ((transfer_size_ >= 0) && (bytes_downloaded_ < transfer_size_)) {
106 // Need to restart transfer 106 // Need to restart transfer
107 retry_count_++; 107 retry_count_++;
108 LOG(INFO) << "Restarting transfer b/c we finished, had downloaded " 108 LOG(INFO) << "Restarting transfer b/c we finished, had downloaded "
109 << bytes_downloaded_ << " bytes, but transfer_size_ is " 109 << bytes_downloaded_ << " bytes, but transfer_size_ is "
110 << transfer_size_ << ". retry_count: " << retry_count_; 110 << transfer_size_ << ". retry_count: " << retry_count_;
111 if (retry_count_ > kMaxRetriesCount) { 111 if (retry_count_ > kMaxRetriesCount) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 curl_handle_ = NULL; 290 curl_handle_ = NULL;
291 } 291 }
292 if (curl_multi_handle_) { 292 if (curl_multi_handle_) {
293 CHECK_EQ(curl_multi_cleanup(curl_multi_handle_), CURLM_OK); 293 CHECK_EQ(curl_multi_cleanup(curl_multi_handle_), CURLM_OK);
294 curl_multi_handle_ = NULL; 294 curl_multi_handle_ = NULL;
295 } 295 }
296 transfer_in_progress_ = false; 296 transfer_in_progress_ = false;
297 } 297 }
298 298
299 } // namespace chromeos_update_engine 299 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698