diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2013-01-10 00:10:26 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2013-01-10 00:10:26 +0000 |
commit | 2d8365d96e1033b2485683652889181a2f999848 (patch) | |
tree | 469f86332c34dcf687f08b703bb7de00255b3d00 | |
parent | 38a3d6f79305ebfc3b5e3caa35d04b9de0da9efb (diff) | |
download | illumos-joyent-2d8365d96e1033b2485683652889181a2f999848.tar.gz |
OS-1794 /usr/sbin/shutdown fails to bring down zone
-rw-r--r-- | usr/src/cmd/init/init.c | 23 | ||||
-rw-r--r-- | usr/src/cmd/svc/startd/graph.c | 13 |
2 files changed, 20 insertions, 16 deletions
diff --git a/usr/src/cmd/init/init.c b/usr/src/cmd/init/init.c index 9cac7b6a0d..d7c8853a08 100644 --- a/usr/src/cmd/init/init.c +++ b/usr/src/cmd/init/init.c @@ -21,7 +21,7 @@ /* * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012, Joyent, Inc. All rights reserved. + * Copyright (c) 2013, Joyent, Inc. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -3508,26 +3508,19 @@ bail: * Attempt to confirm that svc.startd is ready to accept a user-initiated * run-level change. startd is not ready until it has started its * _scf_notify_wait thread to watch for events from svc.configd. This is - * inherently racy. As a heuristic, we check the status of a very early svc - * (CHECK_SVC) to see if that is online. Since we could be booted to milestone - * none, the svc may never be online, so only retry for 5 seconds before - * charging ahead. + * inherently racy. To workaround this, we check the status of a file that + * startd will create once it has started the _scf_notify_wait thread. + * If we don't see this file after one minute, then charge ahead. */ static void verify_startd_ready() { - char *svc_state; + struct stat64 buf; int i; - for (i = 0; i < 5; i++) { - svc_state = smf_get_state(CHECK_SVC); - if (svc_state != NULL) { - if (strcmp(svc_state, SCF_STATE_STRING_ONLINE) == 0) { - free(svc_state); - return; - } - free(svc_state); - } + for (i = 0; i < 60; i++) { + if (stat64("/etc/svc/volatile/startd.ready", &buf) == 0) + return; sleep(1); } console(B_TRUE, "verify startd timeout\n"); diff --git a/usr/src/cmd/svc/startd/graph.c b/usr/src/cmd/svc/startd/graph.c index 1e2af83e58..c8e0872ff8 100644 --- a/usr/src/cmd/svc/startd/graph.c +++ b/usr/src/cmd/svc/startd/graph.c @@ -21,7 +21,7 @@ /* * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2012, Joyent, Inc. All rights reserved. + * Copyright 2013, Joyent, Inc. All rights reserved. */ /* @@ -142,6 +142,8 @@ #include <assert.h> #include <errno.h> #include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> #include <fm/libfmevent.h> #include <libscf.h> #include <libscf_priv.h> @@ -6842,6 +6844,7 @@ repository_event_thread(void *unused) char *fmri = startd_alloc(max_scf_fmri_size); char *pg_name = startd_alloc(max_scf_value_size); int r; + int fd; h = libscf_handle_create_bound_loop(); @@ -6864,6 +6867,14 @@ retry: goto retry; } + if ((fd = open("/etc/svc/volatile/startd.ready", O_RDONLY | O_CREAT, + S_IRUSR)) < 0) { + log_error(LOG_WARNING, "Couldn't create startd.ready file\n", + SCF_GROUP_FRAMEWORK, scf_strerror(scf_error())); + } else { + (void) close(fd); + } + /*CONSTCOND*/ while (1) { ssize_t res; |