Print this page
6805730 some simple changes would make 'init 5' much faster
6809492 startd shouldn't let hung subprocesses impede shutdown

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/svc/startd/method.c
          +++ new/usr/src/cmd/svc/startd/method.c
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  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      - * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
       22 + * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  27      -
  28   26  /*
  29   27   * method.c - method execution functions
  30   28   *
  31   29   * This file contains the routines needed to run a method:  a fork(2)-exec(2)
  32   30   * invocation monitored using either the contract filesystem or waitpid(2).
  33   31   * (Plain fork1(2) support is provided in fork.c.)
  34   32   *
  35   33   * Contract Transfer
  36   34   *   When we restart a service, we want to transfer any contracts that the old
  37   35   *   service's contract inherited.  This means that (a) we must not abandon the
↓ open down ↓ 910 lines elided ↑ open up ↑
 948  946                          timeout -= (end_time - start_time);
 949  947          }
 950  948  
 951  949  assured_kill:
 952  950          /*
 953  951           * For stop methods, assure that the service contract has emptied
 954  952           * before returning.
 955  953           */
 956  954          if (type == METHOD_STOP && (!instance_is_transient_style(inst)) &&
 957  955              !(contract_is_empty(inst->ri_i.i_primary_ctid))) {
      956 +                int times = 0;
 958  957  
 959  958                  if (timeout != METHOD_TIMEOUT_INFINITE)
 960  959                          timeout_insert(inst, inst->ri_i.i_primary_ctid,
 961  960                              timeout);
 962  961  
 963  962                  for (;;) {
 964      -                        (void) poll(NULL, 0, 100);
      963 +                        /*
      964 +                         * Check frequently at first, then back off.  This
      965 +                         * keeps startd from idling while shutting down.
      966 +                         */
      967 +                        if (times < 20) {
      968 +                                (void) poll(NULL, 0, 5);
      969 +                                times++;
      970 +                        } else {
      971 +                                (void) poll(NULL, 0, 100);
      972 +                        }
 965  973                          if (contract_is_empty(inst->ri_i.i_primary_ctid))
 966  974                                  break;
 967  975                  }
 968  976  
 969  977                  if (timeout != METHOD_TIMEOUT_INFINITE)
 970  978                          if (inst->ri_timeout->te_fired)
 971  979                                  result = EFAULT;
 972  980  
 973  981                  timeout_remove(inst, inst->ri_i.i_primary_ctid);
 974  982          }
↓ open down ↓ 192 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX