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

@@ -17,16 +17,14 @@
  * information: Portions Copyright [yyyy] [name of copyright owner]
  *
  * CDDL HEADER END
  */
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident   "%Z%%M% %I%     %E% SMI"
-
 /*
  * method.c - method execution functions
  *
  * This file contains the routines needed to run a method:  a fork(2)-exec(2)
  * invocation monitored using either the contract filesystem or waitpid(2).

@@ -953,17 +951,27 @@
          * For stop methods, assure that the service contract has emptied
          * before returning.
          */
         if (type == METHOD_STOP && (!instance_is_transient_style(inst)) &&
             !(contract_is_empty(inst->ri_i.i_primary_ctid))) {
+                int times = 0;
 
                 if (timeout != METHOD_TIMEOUT_INFINITE)
                         timeout_insert(inst, inst->ri_i.i_primary_ctid,
                             timeout);
 
                 for (;;) {
+                        /*
+                         * Check frequently at first, then back off.  This
+                         * keeps startd from idling while shutting down.
+                         */
+                        if (times < 20) {
+                                (void) poll(NULL, 0, 5);
+                                times++;
+                        } else {
                         (void) poll(NULL, 0, 100);
+                        }
                         if (contract_is_empty(inst->ri_i.i_primary_ctid))
                                 break;
                 }
 
                 if (timeout != METHOD_TIMEOUT_INFINITE)