OLD | NEW |
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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include <base/at_exit.h> | 8 #include <base/at_exit.h> |
9 #include <base/command_line.h> | 9 #include <base/command_line.h> |
10 #include <base/file_util.h> | 10 #include <base/file_util.h> |
(...skipping 23 matching lines...) Expand all Loading... |
34 DEFINE_bool(foreground, false, | 34 DEFINE_bool(foreground, false, |
35 "Don't daemon()ize; run in foreground."); | 35 "Don't daemon()ize; run in foreground."); |
36 | 36 |
37 using std::string; | 37 using std::string; |
38 using std::vector; | 38 using std::vector; |
39 | 39 |
40 namespace chromeos_update_engine { | 40 namespace chromeos_update_engine { |
41 | 41 |
42 gboolean UpdateBootFlags(void* arg) { | 42 gboolean UpdateBootFlags(void* arg) { |
43 UpdateAttempter* attempter = reinterpret_cast<UpdateAttempter*>(arg); | 43 UpdateAttempter* attempter = reinterpret_cast<UpdateAttempter*>(arg); |
44 if (attempter->status() == UPDATE_STATUS_UPDATED_NEED_REBOOT) { | 44 attempter->UpdateBootFlags(); |
45 // Don't update the flags if there's an update that's just been applied and | |
46 // we're waiting for reboot because we may end up reverting the update. | |
47 return FALSE; // Don't call this callback again. | |
48 } | |
49 if (attempter->status() != UPDATE_STATUS_IDLE) { | |
50 // To avoid races (e.g., setting a good kernel right after post-install but | |
51 // before the status changes), update the boot flag only if the attempter is | |
52 // idle. | |
53 return TRUE; // Call this callback again. | |
54 } | |
55 // This is purely best effort. Failures should be logged by Subprocess. | |
56 int unused = 0; | |
57 vector<string> cmd(1, "/usr/sbin/chromeos-setgoodkernel"); | |
58 Subprocess::SynchronousExec(cmd, &unused); | |
59 return FALSE; // Don't call this callback again | 45 return FALSE; // Don't call this callback again |
60 } | 46 } |
61 | 47 |
62 namespace { | 48 namespace { |
63 | 49 |
64 void SetupDbusService(UpdateEngineService* service) { | 50 void SetupDbusService(UpdateEngineService* service) { |
65 DBusGConnection *bus; | 51 DBusGConnection *bus; |
66 DBusGProxy *proxy; | 52 DBusGProxy *proxy; |
67 GError *error = NULL; | 53 GError *error = NULL; |
68 | 54 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 g_main_loop_run(loop); | 194 g_main_loop_run(loop); |
209 | 195 |
210 // Cleanup: | 196 // Cleanup: |
211 g_main_loop_unref(loop); | 197 g_main_loop_unref(loop); |
212 update_attempter.set_dbus_service(NULL); | 198 update_attempter.set_dbus_service(NULL); |
213 g_object_unref(G_OBJECT(service)); | 199 g_object_unref(G_OBJECT(service)); |
214 | 200 |
215 LOG(INFO) << "Chrome OS Update Engine terminating"; | 201 LOG(INFO) << "Chrome OS Update Engine terminating"; |
216 return 0; | 202 return 0; |
217 } | 203 } |
OLD | NEW |