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

Unified Diff: main.cc

Issue 3980005: AU: Don't mark booted kernel good if we've applied an update. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: avoid race conditions Created 10 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: main.cc
diff --git a/main.cc b/main.cc
index 94393c3bb5033f6d6011d2c0395debf69654d49a..571f33782905970c700a625a07ebe34cf1c68c40 100644
--- a/main.cc
+++ b/main.cc
@@ -40,7 +40,19 @@ using std::vector;
namespace chromeos_update_engine {
gboolean UpdateBootFlags(void* arg) {
- // This purely best effort. Failures should be logged by Subprocess.
+ UpdateAttempter* attempter = reinterpret_cast<UpdateAttempter*>(arg);
+ if (attempter->status() == UPDATE_STATUS_UPDATED_NEED_REBOOT) {
+ // Don't update the flags if there's an update that's just been applied and
+ // we're waiting for reboot because we may end up reverting the update.
+ return FALSE; // Don't call this callback again.
+ }
+ if (attempter->status() != UPDATE_STATUS_IDLE) {
adlr 2010/10/22 00:45:28 since it's single threaded, and this and postinst
+ // To avoid races (e.g., setting a good kernel right after post-install but
+ // before the status changes), update the boot flag only if the attempter is
+ // idle.
+ return TRUE; // Call this callback again.
+ }
+ // This is purely best effort. Failures should be logged by Subprocess.
int unused = 0;
vector<string> cmd(1, "/usr/sbin/chromeos-setgoodkernel");
Subprocess::SynchronousExec(cmd, &unused);
@@ -142,8 +154,10 @@ int main(int argc, char** argv) {
chromeos_update_engine::UpdateCheckScheduler scheduler(&update_attempter);
scheduler.Run();
- // Update boot flags after 45 seconds
- g_timeout_add_seconds(45, &chromeos_update_engine::UpdateBootFlags, NULL);
+ // Update boot flags after 45 seconds.
+ g_timeout_add_seconds(45,
+ &chromeos_update_engine::UpdateBootFlags,
+ &update_attempter);
// Run the main loop until exit time:
g_main_loop_run(loop);
« 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