diff options
author | John Sonnenschein <johns@joyent.com> | 2012-05-17 18:26:57 +0000 |
---|---|---|
committer | John Sonnenschein <johns@joyent.com> | 2012-05-17 18:26:57 +0000 |
commit | 04b244dd661c24b510ac22936decfc0972d202d3 (patch) | |
tree | 3ebfef98afc303fddf3415d6fba64e8682f495e8 /usr/src/cmd/svc | |
parent | eac250589e41f1b705e1b7427b02b3379aac9f9e (diff) | |
parent | a69187741b83640a90dd8586195456dd50c016a8 (diff) | |
download | illumos-joyent-20120517.tar.gz |
Merge git.joyent.com:illumos-joyent20120517
Diffstat (limited to 'usr/src/cmd/svc')
-rw-r--r-- | usr/src/cmd/svc/milestone/net-nwam | 19 | ||||
-rw-r--r-- | usr/src/cmd/svc/milestone/net-physical | 11 | ||||
-rw-r--r-- | usr/src/cmd/svc/shell/smf_include.sh | 6 | ||||
-rw-r--r-- | usr/src/cmd/svc/startd/method.c | 25 | ||||
-rw-r--r-- | usr/src/cmd/svc/startd/restarter.c | 40 | ||||
-rw-r--r-- | usr/src/cmd/svc/startd/startd.c | 15 |
6 files changed, 87 insertions, 29 deletions
diff --git a/usr/src/cmd/svc/milestone/net-nwam b/usr/src/cmd/svc/milestone/net-nwam index efc7236e40..9f1de2fd76 100644 --- a/usr/src/cmd/svc/milestone/net-nwam +++ b/usr/src/cmd/svc/milestone/net-nwam @@ -21,6 +21,7 @@ # # # Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2012 Milan Jurik. All rights reserved. # . /lib/svc/share/smf_include.sh @@ -537,15 +538,17 @@ case "$1" in # # Upgrade handling for ibd: - # After we are done with the upgrade handling, we can not set the - # ibd/ibd_upgraded property to "true" as the file system is - # read-only at this point. It will be done later by ibd-post-upgrade - # service. + # After we are done with the upgrade handling, we can not set + # the ibd/ibd_upgraded property to "true" as the file system is + # read-only at this point. It will be done later by + # ibd-post-upgrade service. # - ibd_upgraded=`/bin/svcprop -c -p ibd/ibd_upgraded \ - svc:/network/physical:default 2> /dev/null` - if [ "$ibd_upgraded" != "true" ]; then - /sbin/ibd_upgrade -v + if [ -x /sbin/ibd_upgrade ]; then + ibd_upgraded=`/bin/svcprop -c -p ibd/ibd_upgraded \ + svc:/network/physical:default 2> /dev/null` + if [ "$ibd_upgraded" != "true" ]; then + /sbin/ibd_upgrade -v + fi fi # Bring up simnet instances diff --git a/usr/src/cmd/svc/milestone/net-physical b/usr/src/cmd/svc/milestone/net-physical index 3a873db121..89784dcbbc 100644 --- a/usr/src/cmd/svc/milestone/net-physical +++ b/usr/src/cmd/svc/milestone/net-physical @@ -21,6 +21,7 @@ # # # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2012 Milan Jurik. All rights reserved. # # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. # All rights reserved. @@ -67,10 +68,12 @@ if smf_is_globalzone; then # read-only at this point. It will be done later by ibd-post-upgrade # service. # - ibd_upgraded=`/bin/svcprop -c -p ibd/ibd_upgraded \ - $SMF_FMRI 2> /dev/null` - if [ "$ibd_upgraded" != "true" ]; then - /sbin/ibd_upgrade -v + if [ -x /sbin/ibd_upgrade ]; then + ibd_upgraded=`/bin/svcprop -c -p ibd/ibd_upgraded \ + $SMF_FMRI 2> /dev/null` + if [ "$ibd_upgraded" != "true" ]; then + /sbin/ibd_upgrade -v + fi fi # diff --git a/usr/src/cmd/svc/shell/smf_include.sh b/usr/src/cmd/svc/shell/smf_include.sh index d0dc387246..02c9532763 100644 --- a/usr/src/cmd/svc/shell/smf_include.sh +++ b/usr/src/cmd/svc/shell/smf_include.sh @@ -22,6 +22,7 @@ # # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. +# Copyright 2012 Joyent, Inc. All rights reserved. # smf_present () { @@ -234,7 +235,12 @@ smf_kill_contract() { # SMF_EXIT_ERR_OTHER, although not defined, encompasses all non-zero # exit status values. # +# The SMF_EXIT_NODAEMON exit status should be used when a method does not +# need to run any persistent process. This indicates success, abandons the +# contract, and allows dependencies to be met. +# SMF_EXIT_OK=0 +SMF_EXIT_NODAEMON=94 SMF_EXIT_ERR_FATAL=95 SMF_EXIT_ERR_CONFIG=96 SMF_EXIT_MON_DEGRADE=97 diff --git a/usr/src/cmd/svc/startd/method.c b/usr/src/cmd/svc/startd/method.c index ddc0e5e844..076003e6c6 100644 --- a/usr/src/cmd/svc/startd/method.c +++ b/usr/src/cmd/svc/startd/method.c @@ -21,11 +21,7 @@ /* * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2011 Joyent Inc. - */ - -/* - * Copyright 2011 Joyent Inc. + * Copyright 2012 Joyent, Inc. All rights reserved. */ /* @@ -933,7 +929,8 @@ method_run(restarter_inst_t **instp, int type, int *exit_code) goto contract_out; } - if (!WIFEXITED(ret_status)) { + if (!WIFEXITED(ret_status) && + WEXITSTATUS(ret_status) != SMF_EXIT_NODAEMON) { /* * If method didn't exit itself (it was killed by an * external entity, etc.), consider the entire @@ -962,7 +959,7 @@ method_run(restarter_inst_t **instp, int type, int *exit_code) } *exit_code = WEXITSTATUS(ret_status); - if (*exit_code != 0) { + if (*exit_code != 0 && *exit_code != SMF_EXIT_NODAEMON) { log_error(LOG_WARNING, "%s: Method \"%s\" failed with exit status %d.\n", inst->ri_i.i_fmri, method, WEXITSTATUS(ret_status)); @@ -971,6 +968,7 @@ method_run(restarter_inst_t **instp, int type, int *exit_code) log_instance(inst, B_TRUE, "Method \"%s\" exited with status " "%d.", mname, *exit_code); + /* Note: we will take this path for SMF_EXIT_NODAEMON */ if (*exit_code != 0) goto contract_out; @@ -1017,7 +1015,10 @@ assured_kill: } contract_out: - /* Abandon contracts for transient methods & methods that fail. */ + /* + * Abandon contracts for transient methods, methods that exit with + * SMF_EXIT_NODAEMON & methods that fail. + */ transient = method_is_transient(inst, type); if ((transient || *exit_code != 0 || result != 0) && (restarter_is_kill_method(method) < 0)) @@ -1113,7 +1114,7 @@ retry: r = method_run(&inst, info->sf_method_type, &exit_code); - if (r == 0 && exit_code == 0) { + if (r == 0 && (exit_code == 0 || exit_code == SMF_EXIT_NODAEMON)) { /* Success! */ assert(inst->ri_i.i_next_state != RESTARTER_STATE_NONE); @@ -1131,6 +1132,12 @@ retry: else method_remove_contract(inst, B_TRUE, B_TRUE); } + + /* + * For methods that exit with SMF_EXIT_NODAEMON, we already + * called method_remove_contract in method_run. + */ + /* * We don't care whether the handle was rebound because this is * the last thing we do with it. diff --git a/usr/src/cmd/svc/startd/restarter.c b/usr/src/cmd/svc/startd/restarter.c index a088592d14..a55fb489ad 100644 --- a/usr/src/cmd/svc/startd/restarter.c +++ b/usr/src/cmd/svc/startd/restarter.c @@ -373,9 +373,11 @@ rep_retry: if (inst->ri_logstem != NULL) startd_free(inst->ri_logstem, PATH_MAX); if (inst->ri_common_name != NULL) - startd_free(inst->ri_common_name, max_scf_value_size); + startd_free(inst->ri_common_name, + strlen(inst->ri_common_name) + 1); if (inst->ri_C_common_name != NULL) - startd_free(inst->ri_C_common_name, max_scf_value_size); + startd_free(inst->ri_C_common_name, + strlen(inst->ri_C_common_name) + 1); snap = NULL; inst->ri_logstem = NULL; inst->ri_common_name = NULL; @@ -529,8 +531,25 @@ rep_retry: abort(); } - switch (libscf_get_template_values(scf_inst, snap, - &inst->ri_common_name, &inst->ri_C_common_name)) { + r = libscf_get_template_values(scf_inst, snap, + &inst->ri_common_name, &inst->ri_C_common_name); + + /* + * Copy our names to smaller buffers to reduce our memory footprint. + */ + if (inst->ri_common_name != NULL) { + char *tmp = safe_strdup(inst->ri_common_name); + startd_free(inst->ri_common_name, max_scf_value_size); + inst->ri_common_name = tmp; + } + + if (inst->ri_C_common_name != NULL) { + char *tmp = safe_strdup(inst->ri_C_common_name); + startd_free(inst->ri_C_common_name, max_scf_value_size); + inst->ri_C_common_name = tmp; + } + + switch (r) { case 0: break; @@ -678,9 +697,11 @@ deleted: if (inst->ri_logstem != NULL) startd_free(inst->ri_logstem, PATH_MAX); if (inst->ri_common_name != NULL) - startd_free(inst->ri_common_name, max_scf_value_size); + startd_free(inst->ri_common_name, + strlen(inst->ri_common_name) + 1); if (inst->ri_C_common_name != NULL) - startd_free(inst->ri_C_common_name, max_scf_value_size); + startd_free(inst->ri_C_common_name, + strlen(inst->ri_C_common_name) + 1); startd_free(inst->ri_utmpx_prefix, max_scf_value_size); startd_free(inst, sizeof (restarter_inst_t)); return (ENOENT); @@ -740,9 +761,11 @@ restarter_delete_inst(restarter_inst_t *ri) startd_free((void *)ri->ri_i.i_fmri, strlen(ri->ri_i.i_fmri) + 1); startd_free(ri->ri_logstem, PATH_MAX); if (ri->ri_common_name != NULL) - startd_free(ri->ri_common_name, max_scf_value_size); + startd_free(ri->ri_common_name, + strlen(ri->ri_common_name) + 1); if (ri->ri_C_common_name != NULL) - startd_free(ri->ri_C_common_name, max_scf_value_size); + startd_free(ri->ri_C_common_name, + strlen(ri->ri_C_common_name) + 1); startd_free(ri->ri_utmpx_prefix, max_scf_value_size); (void) pthread_mutex_destroy(&ri->ri_lock); (void) pthread_mutex_destroy(&ri->ri_queue_lock); @@ -1841,6 +1864,7 @@ cont: rip->ri_queue_thread = 0; MUTEX_UNLOCK(&rip->ri_queue_lock); + out: (void) scf_handle_unbind(h); scf_handle_destroy(h); diff --git a/usr/src/cmd/svc/startd/startd.c b/usr/src/cmd/svc/startd/startd.c index f0c57d37eb..14180c5f54 100644 --- a/usr/src/cmd/svc/startd/startd.c +++ b/usr/src/cmd/svc/startd/startd.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, Joyent, Inc. All rights reserved. */ /* @@ -143,6 +144,7 @@ static uint8_t prop_reconfig = 0; pthread_mutexattr_t mutex_attrs; +#ifdef DEBUG const char * _umem_debug_init(void) { @@ -154,6 +156,19 @@ _umem_logging_init(void) { return ("fail,contents"); /* UMEM_LOGGING setting */ } +#endif + +const char * +_umem_options_init(void) +{ + /* + * To reduce our memory footprint, we set our UMEM_OPTIONS to indicate + * that we do not wish to have per-CPU magazines -- if svc.startd is so + * hot on CPU such that this becomes a scalability problem, there are + * likely deeper things amiss... + */ + return ("nomagazines"); /* UMEM_OPTIONS setting */ +} /* * startd_alloc_retry() |