diff options
| author | John Sonnenschein <johns@joyent.com> | 2011-03-17 10:05:13 -0700 |
|---|---|---|
| committer | John Sonnenschein <johns@joyent.com> | 2011-03-17 12:48:11 -0700 |
| commit | 44617144cce2bbd335caf38e75522f02cdab3484 (patch) | |
| tree | 04d3f49d8a50dde91db041646bb0013f80130fd1 | |
| parent | a5c2501f94a7811ea6f4fd115de2984115fe1949 (diff) | |
| download | illumos-joyent-44617144cce2bbd335caf38e75522f02cdab3484.tar.gz | |
OS-275 smf behavior around going to maint causes problems. (change prop name, fix cstyle)
| -rw-r--r-- | usr/src/cmd/svc/startd/method.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/usr/src/cmd/svc/startd/method.c b/usr/src/cmd/svc/startd/method.c index 440ba348ee..fba6c7c39e 100644 --- a/usr/src/cmd/svc/startd/method.c +++ b/usr/src/cmd/svc/startd/method.c @@ -75,6 +75,7 @@ #include <atomic.h> #include <poll.h> #include <libscf_priv.h> + #include "startd.h" #define SBIN_SH "/sbin/sh" @@ -115,22 +116,26 @@ method_record_start(restarter_inst_t *inst) * method_rate_critical(restarter_inst_t *) * Return true if the average start interval is less than the permitted * interval. The implicit interval defaults to RINST_FAILURE_RATE_NS and - * RINST_START_TIMES but is overridable with the - * startd/critical_failure_rate and startd/critical_start_times properties + * RINST_START_TIMES but may be overridden with the svc properties + * startd/critical_failure_count and startd/critical_failure_period + * which represent the number of failures to consider and the amount of + * time in seconds in which that number may occur, respectively. Note that + * this time is measured as of the transition to 'enabled' rather than wall + * clock time. * Implicit success if insufficient measurements for an average exist. */ static int method_rate_critical(restarter_inst_t *inst) { - hrtime_t critical_failure_rate = RINST_FAILURE_RATE_NS; - uint_t critical_start_times = RINST_START_TIMES; + hrtime_t critical_failure_period = RINST_FAILURE_RATE_NS; + uint_t critical_failure_count = RINST_START_TIMES; uint_t n = inst->ri_start_index; hrtime_t avg_ns = 0; uint64_t scf_fr, scf_st; scf_propvec_t *prop = NULL; scf_propvec_t restart_critical[] = { - { "critical_failure_rate", NULL, SCF_TYPE_INTEGER, NULL, 0 }, - { "critical_start_times", NULL, SCF_TYPE_INTEGER, NULL, 0 }, + { "critical_failure_period", NULL, SCF_TYPE_INTEGER, NULL, 0 }, + { "critical_failure_count", NULL, SCF_TYPE_INTEGER, NULL, 0 }, { NULL } }; @@ -139,19 +144,22 @@ method_rate_critical(restarter_inst_t *inst) if (scf_read_propvec(inst->ri_i.i_fmri, "startd", B_TRUE, restart_critical, &prop) != SCF_FAILED) { - /* failure rate is defined in 1s intervals, but implemented in ns */ - critical_failure_rate = (hrtime_t) scf_fr * 1000000000; - critical_start_times = (uint_t) scf_st; + /* + * critical_failure_period is expressed + * in seconds but tracked in ns + */ + critical_failure_period = (hrtime_t) scf_fr * NANOSEC; + critical_failure_count = (uint_t) scf_st; } - if (inst->ri_start_index < critical_start_times) - return (0); + if (inst->ri_start_index < critical_failure_count) + return (0); avg_ns = - (inst->ri_start_time[(n - 1) % critical_start_times] - - inst->ri_start_time[n % critical_start_times]) / - (critical_start_times - 1); + (inst->ri_start_time[(n - 1) % critical_failure_count] - + inst->ri_start_time[n % critical_failure_count]) / + (critical_failure_count - 1); - return (avg_ns < critical_failure_rate); + return (avg_ns < critical_failure_period); } /* |
