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

Side by Side Diff: update_attempter.cc

Issue 4191002: AU: Nice for 2 hours, then normal priority. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « update_attempter.h ('k') | 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) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 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/update_attempter.h" 5 #include "update_engine/update_attempter.h"
6 6
7 // From 'man clock_gettime': feature test macro: _POSIX_C_SOURCE >= 199309L 7 // From 'man clock_gettime': feature test macro: _POSIX_C_SOURCE >= 199309L
8 #ifndef _POSIX_C_SOURCE 8 #ifndef _POSIX_C_SOURCE
9 #define _POSIX_C_SOURCE 199309L 9 #define _POSIX_C_SOURCE 199309L
10 #endif // _POSIX_C_SOURCE 10 #endif // _POSIX_C_SOURCE
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 priority_ = priority; 465 priority_ = priority;
466 LOG(INFO) << "Process priority = " << priority_; 466 LOG(INFO) << "Process priority = " << priority_;
467 } 467 }
468 } 468 }
469 469
470 void UpdateAttempter::SetupPriorityManagement() { 470 void UpdateAttempter::SetupPriorityManagement() {
471 if (manage_priority_source_) { 471 if (manage_priority_source_) {
472 LOG(ERROR) << "Process priority timeout source hasn't been destroyed."; 472 LOG(ERROR) << "Process priority timeout source hasn't been destroyed.";
473 CleanupPriorityManagement(); 473 CleanupPriorityManagement();
474 } 474 }
475 const int kPriorityTimeout = 10 * 60; // 10 minutes 475 const int kPriorityTimeout = 2 * 60 * 60; // 2 hours
476 manage_priority_source_ = g_timeout_source_new_seconds(kPriorityTimeout); 476 manage_priority_source_ = g_timeout_source_new_seconds(kPriorityTimeout);
477 g_source_set_callback(manage_priority_source_, 477 g_source_set_callback(manage_priority_source_,
478 StaticManagePriorityCallback, 478 StaticManagePriorityCallback,
479 this, 479 this,
480 NULL); 480 NULL);
481 g_source_attach(manage_priority_source_, NULL); 481 g_source_attach(manage_priority_source_, NULL);
482 SetPriority(utils::kProcessPriorityLow); 482 SetPriority(utils::kProcessPriorityLow);
483 } 483 }
484 484
485 void UpdateAttempter::CleanupPriorityManagement() { 485 void UpdateAttempter::CleanupPriorityManagement() {
486 if (manage_priority_source_) { 486 if (manage_priority_source_) {
487 g_source_destroy(manage_priority_source_); 487 g_source_destroy(manage_priority_source_);
488 manage_priority_source_ = NULL; 488 manage_priority_source_ = NULL;
489 } 489 }
490 SetPriority(utils::kProcessPriorityNormal); 490 SetPriority(utils::kProcessPriorityNormal);
491 } 491 }
492 492
493 gboolean UpdateAttempter::StaticManagePriorityCallback(gpointer data) { 493 gboolean UpdateAttempter::StaticManagePriorityCallback(gpointer data) {
494 return reinterpret_cast<UpdateAttempter*>(data)->ManagePriorityCallback(); 494 return reinterpret_cast<UpdateAttempter*>(data)->ManagePriorityCallback();
495 } 495 }
496 496
497 bool UpdateAttempter::ManagePriorityCallback() { 497 bool UpdateAttempter::ManagePriorityCallback() {
498 // If the current process priority is below normal, set it to normal 498 SetPriority(utils::kProcessPriorityNormal);
499 // and let GLib invoke this callback again.
500 if (utils::ComparePriorities(priority_, utils::kProcessPriorityNormal) < 0) {
501 SetPriority(utils::kProcessPriorityNormal);
502 return true;
503 }
504 // Set the priority to high and let GLib destroy the timeout source.
505 SetPriority(utils::kProcessPriorityHigh);
506 manage_priority_source_ = NULL; 499 manage_priority_source_ = NULL;
507 return false; 500 return false; // Destroy the timeout source.
508 } 501 }
509 502
510 void UpdateAttempter::DisableDeltaUpdateIfNeeded() { 503 void UpdateAttempter::DisableDeltaUpdateIfNeeded() {
511 int64_t delta_failures; 504 int64_t delta_failures;
512 if (omaha_request_params_.delta_okay && 505 if (omaha_request_params_.delta_okay &&
513 prefs_->GetInt64(kPrefsDeltaUpdateFailures, &delta_failures) && 506 prefs_->GetInt64(kPrefsDeltaUpdateFailures, &delta_failures) &&
514 delta_failures >= kMaxDeltaUpdateFailures) { 507 delta_failures >= kMaxDeltaUpdateFailures) {
515 LOG(WARNING) << "Too many delta update failures, forcing full update."; 508 LOG(WARNING) << "Too many delta update failures, forcing full update.";
516 omaha_request_params_.delta_okay = false; 509 omaha_request_params_.delta_okay = false;
517 } 510 }
(...skipping 30 matching lines...) Expand all
548 if (resume_offset < response_handler_action_->install_plan().size) { 541 if (resume_offset < response_handler_action_->install_plan().size) {
549 ranges.push_back(make_pair(resume_offset, -1)); 542 ranges.push_back(make_pair(resume_offset, -1));
550 } 543 }
551 } else { 544 } else {
552 ranges.push_back(make_pair(0, -1)); 545 ranges.push_back(make_pair(0, -1));
553 } 546 }
554 fetcher->set_ranges(ranges); 547 fetcher->set_ranges(ranges);
555 } 548 }
556 549
557 } // namespace chromeos_update_engine 550 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « update_attempter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698