Print this page
7267 SMF is fast and loose with optional dependencies
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Albert Lee <trisk@omniti.com>
Reviewed by: Gordon Ross <gordon.w.ross@gmail.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/svc/startd/transition.c
          +++ new/usr/src/cmd/svc/startd/transition.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + *
       25 + * Copyright 2016 RackTop Systems.
  24   26   */
  25   27  
  26   28  
  27   29  /*
  28   30   * transition.c - Graph State Machine
  29   31   *
  30   32   * The graph state machine is implemented here, with a typical approach
  31   33   * of a function per state.  Separating the implementation allows more
  32   34   * clarity into the actions taken on notification of state change, as well
  33   35   * as a place for future expansion including hooks for configurable actions.
↓ open down ↓ 96 lines elided ↑ open up ↑
 130  132                          log_framework(LOG_DEBUG, "%s removed from subtree\n",
 131  133                              v->gv_name);
 132  134  
 133  135                          graph_offline_subtree_leaves(v, (void *)h);
 134  136                  }
 135  137  
 136  138                  log_framework(LOG_DEBUG, "Propagating maintenance (stop) of "
 137  139                      "%s.\n", v->gv_name);
 138  140  
 139  141                  graph_transition_propagate(v, PROPAGATE_STOP, rerr);
      142 +
      143 +                /*
      144 +                 * The maintenance transition may satisfy optional_all/restart
      145 +                 * dependencies and should be propagated to determine
      146 +                 * whether new dependents are satisfiable.
      147 +                 */
      148 +                graph_transition_propagate(v, PROPAGATE_SAT, rerr);
 140  149          } else {
 141  150                  log_framework(LOG_DEBUG, "Propagating maintenance of %s.\n",
 142  151                      v->gv_name);
 143  152  
 144  153                  graph_transition_propagate(v, PROPAGATE_SAT, rerr);
 145  154          }
 146  155  
 147  156          graph_transition_sulogin(RESTARTER_STATE_MAINT, old_state);
 148  157          return (0);
 149  158  }
 150  159  
 151  160  /* ARGSUSED */
 152  161  static int
 153  162  gt_enter_offline(scf_handle_t *h, graph_vertex_t *v,
 154  163      restarter_instance_state_t old_state, restarter_error_t rerr)
 155  164  {
 156  165          int to_offline = v->gv_flags & GV_TOOFFLINE;
      166 +        int to_disable = v->gv_flags & GV_TODISABLE;
 157  167  
 158  168          v->gv_flags &= ~GV_TOOFFLINE;
 159  169  
 160  170          /*
 161  171           * If the instance should be enabled, see if we can start it.
 162  172           * Otherwise send a disable command.
 163  173           * If a instance has the GV_TOOFFLINE flag set then it must
 164  174           * remains offline until the disable process completes.
 165  175           */
 166  176          if (v->gv_flags & GV_ENABLED) {
 167      -                if (to_offline == 0)
      177 +                if (to_offline == 0 && to_disable == 0)
 168  178                          graph_start_if_satisfied(v);
 169  179          } else {
 170  180                  if (gt_running(old_state) && v->gv_post_disable_f)
 171  181                          v->gv_post_disable_f();
 172  182  
 173  183                  vertex_send_event(v, RESTARTER_EVENT_TYPE_DISABLE);
 174  184          }
 175  185  
 176  186          /*
 177  187           * If the service was running, propagate a stop event.  If the
↓ open down ↓ 82 lines elided ↑ open up ↑
 260  270                           */
 261  271                          graph_offline_subtree_leaves(v, (void *)h);
 262  272                  }
 263  273  
 264  274  
 265  275                  log_framework(LOG_DEBUG, "Propagating stop of %s.\n",
 266  276                      v->gv_name);
 267  277  
 268  278                  graph_transition_propagate(v, PROPAGATE_STOP, rerr);
 269  279  
      280 +                /*
      281 +                 * The disable transition may satisfy optional_all/restart
      282 +                 * dependencies and should be propagated to determine
      283 +                 * whether new dependents are satisfiable.
      284 +                 */
      285 +                graph_transition_propagate(v, PROPAGATE_SAT, rerr);
 270  286          } else {
 271  287                  log_framework(LOG_DEBUG, "Propagating disable of %s.\n",
 272  288                      v->gv_name);
 273  289  
 274  290                  graph_transition_propagate(v, PROPAGATE_SAT, rerr);
 275  291          }
 276  292  
 277  293          graph_transition_sulogin(RESTARTER_STATE_DISABLED, old_state);
 278  294          return (0);
 279  295  }
↓ open down ↓ 190 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX