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

Side by Side Diff: session_manager_service.cc

Issue 661224: Stop infinite restarting (Closed)
Patch Set: Created 10 years, 9 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
OLDNEW
1 // Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009-2010 The Chromium 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 "login_manager/session_manager_service.h" 5 #include "login_manager/session_manager_service.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <glib.h> 8 #include <glib.h>
9 #include <grp.h> 9 #include <grp.h>
10 #include <sys/errno.h> 10 #include <sys/errno.h>
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 g_main_loop_run(main_loop_); 192 g_main_loop_run(main_loop_);
193 193
194 if (child_pid_ != 0) // otherwise, we never created a child. 194 if (child_pid_ != 0) // otherwise, we never created a child.
195 CleanupChildren(3); 195 CleanupChildren(3);
196 196
197 return true; 197 return true;
198 } 198 }
199 199
200 int SessionManagerService::RunChild() { 200 int SessionManagerService::RunChild() {
201 child_job_->RecordTime();
201 int pid = fork(); 202 int pid = fork();
202 if (pid == 0) { 203 if (pid == 0) {
203 // In the child. 204 // In the child.
204 child_job_->Run(); 205 child_job_->Run();
205 exit(1); // Run() is not supposed to return. 206 exit(1); // Run() is not supposed to return.
206 } 207 }
207 g_child_watch_add_full(G_PRIORITY_HIGH_IDLE, 208 g_child_watch_add_full(G_PRIORITY_HIGH_IDLE,
208 pid, 209 pid,
209 HandleChildExit, 210 HandleChildExit,
210 this, 211 this,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 CHECK(WEXITSTATUS(status) != SetUidExecJob::kCantSetuid); 310 CHECK(WEXITSTATUS(status) != SetUidExecJob::kCantSetuid);
310 CHECK(WEXITSTATUS(status) != SetUidExecJob::kCantExec); 311 CHECK(WEXITSTATUS(status) != SetUidExecJob::kCantExec);
311 } else { 312 } else {
312 DLOG(INFO) << " Exited...somehow, without an exit code or a signal??"; 313 DLOG(INFO) << " Exited...somehow, without an exit code or a signal??";
313 } 314 }
314 315
315 bool exited_clean = WIFEXITED(status) && WEXITSTATUS(status) == 0; 316 bool exited_clean = WIFEXITED(status) && WEXITSTATUS(status) == 0;
316 317
317 // If the child _ever_ exits uncleanly, we want to start it up again. 318 // If the child _ever_ exits uncleanly, we want to start it up again.
318 SessionManagerService* manager = static_cast<SessionManagerService*>(data); 319 SessionManagerService* manager = static_cast<SessionManagerService*>(data);
319 if (exited_clean) { 320 if (exited_clean || manager->should_stop_child()) {
320 ServiceShutdown(data); 321 ServiceShutdown(data);
321 } else if (manager->should_run_child()) { 322 } else if (manager->should_run_child()) {
322 // TODO(cmasone): deal with fork failing in RunChild() 323 // TODO(cmasone): deal with fork failing in RunChild()
323 LOG(INFO) << "Running the child again..."; 324 LOG(INFO) << "Running the child again...";
324 manager->set_child_pid(manager->RunChild()); 325 manager->set_child_pid(manager->RunChild());
325 } else { 326 } else {
326 LOG(INFO) << "Should NOT run"; 327 LOG(INFO) << "Should NOT run";
327 manager->AllowGracefulExit(); 328 manager->AllowGracefulExit();
328 } 329 }
329 } 330 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 system_->kill(child_pid_, SIGKILL); 398 system_->kill(child_pid_, SIGKILL);
398 } 399 }
399 400
400 void SessionManagerService::SetGError(GError** error, 401 void SessionManagerService::SetGError(GError** error,
401 ChromeOSLoginError code, 402 ChromeOSLoginError code,
402 const char* message) { 403 const char* message) {
403 g_set_error(error, CHROMEOS_LOGIN_ERROR, code, "Login error: %s", message); 404 g_set_error(error, CHROMEOS_LOGIN_ERROR, code, "Login error: %s", message);
404 } 405 }
405 406
406 } // namespace login_manager 407 } // namespace login_manager
OLDNEW
« child_job.cc ('K') | « session_manager_service.h ('k') | session_manager_setup.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698