Print this page
7711 SMF: Finish implementing support for degraded state

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/svc/startd/method.c
          +++ new/usr/src/cmd/svc/startd/method.c
↓ open down ↓ 1161 lines elided ↑ open up ↑
1162 1162  
1163 1163          inst->ri_m_inst = s_inst;
1164 1164          inst->ri_mi_deleted = B_FALSE;
1165 1165  
1166 1166  retry:
1167 1167          if (info->sf_method_type == METHOD_START)
1168 1168                  log_transition(inst, START_REQUESTED);
1169 1169  
1170 1170          r = method_run(&inst, info->sf_method_type, &exit_code);
1171 1171  
1172      -        if (r == 0 && exit_code == 0) {
     1172 +        if (r == 0 && (exit_code == 0 || exit_code == SMF_EXIT_MON_DEGRADE)) {
1173 1173                  /* Success! */
1174 1174                  assert(inst->ri_i.i_next_state != RESTARTER_STATE_NONE);
1175 1175  
1176 1176                  /*
1177 1177                   * When a stop method succeeds, remove the primary contract of
1178 1178                   * the service, unless we're going to offline, in which case
1179 1179                   * retain the contract so we can transfer inherited contracts to
1180 1180                   * the replacement service.
1181 1181                   */
1182 1182  
1183 1183                  if (info->sf_method_type == METHOD_STOP &&
1184 1184                      inst->ri_i.i_primary_ctid != 0) {
1185 1185                          if (inst->ri_i.i_next_state == RESTARTER_STATE_OFFLINE)
1186 1186                                  inst->ri_i.i_primary_ctid_stopped = 1;
1187 1187                          else
1188 1188                                  method_remove_contract(inst, B_TRUE, B_TRUE);
1189 1189                  }
     1190 +
1190 1191                  /*
     1192 +                 * When a start method returns with SMF_EXIT_MON_DEGRADE we
     1193 +                 * transition the service into degraded.
     1194 +                 */
     1195 +                if (info->sf_method_type == METHOD_START &&
     1196 +                    exit_code == SMF_EXIT_MON_DEGRADE) {
     1197 +                        inst->ri_i.i_next_state = RESTARTER_STATE_DEGRADED;
     1198 +                        info->sf_reason = restarter_str_method_failed;
     1199 +                }
     1200 +
     1201 +                /*
1191 1202                   * We don't care whether the handle was rebound because this is
1192 1203                   * the last thing we do with it.
1193 1204                   */
1194 1205                  (void) restarter_instance_update_states(local_handle, inst,
1195 1206                      inst->ri_i.i_next_state, RESTARTER_STATE_NONE,
1196 1207                      info->sf_event_type, info->sf_reason);
1197 1208  
1198 1209                  (void) update_fault_count(inst, FAULT_COUNT_RESET);
1199 1210  
1200 1211                  goto out;
↓ open down ↓ 66 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX