From nobody@FreeBSD.org  Wed Mar 18 06:00:39 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 477A6106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 18 Mar 2009 06:00:39 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 360468FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 18 Mar 2009 06:00:39 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n2I60cXa008505
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 18 Mar 2009 06:00:38 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n2I60ct2008504;
	Wed, 18 Mar 2009 06:00:38 GMT
	(envelope-from nobody)
Message-Id: <200903180600.n2I60ct2008504@www.freebsd.org>
Date: Wed, 18 Mar 2009 06:00:38 GMT
From: KOIE Hidetaka <hide@koie.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: wait_for_pids() in /etc/rc.subr is dull.
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         132766
>Category:       conf
>Synopsis:       wait_for_pids() in /etc/rc.subr is dull.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dougb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 18 06:10:04 UTC 2009
>Closed-Date:    Thu Nov 19 23:11:15 UTC 2009
>Last-Modified:  Sun Mar 28 20:20:02 UTC 2010
>Originator:     KOIE Hidetaka
>Release:        CURRENT
>Organization:
surigiken
>Environment:
FreeBSD guriandgura 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Thu Feb  5 04:32:41 JST 2009     koie@guriandgura:/usr/obj/usr/src/sys/GURIANDGURA  amd64
>Description:
wait_for_pids() in /etc/rc.subr uses sleep 2 to wait.
but, daemons usually exit before within 2 seconds in my environment.
I propose short sleep.

>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- /usr/src/etc/rc.subr	2008-11-01 09:21:29.578401768 +0900
+++ /etc/rc.subr	2009-03-10 18:26:12.000000000 +0900
@@ -351,7 +351,9 @@ wait_for_pids()
 		return
 	fi
 	_prefix=
+	_slp_list=0.5
 	while true; do
+		for _slp in $_slp_list; do
 		_nlist="";
 		for _j in $_list; do
 			if kill -0 $_j 2>/dev/null; then
@@ -362,9 +364,14 @@ wait_for_pids()
 			break
 		fi
 		_list=$_nlist
+			sleep $_slp
+		done
+		if [ -z "$_nlist" ]; then
+			break
+		fi
 		echo -n ${_prefix:-"Waiting for PIDS: "}$_list
 		_prefix=", "
-		sleep 2
+		_slp_list="0.2 0.4 0.6 0.8"
 	done
 	if [ -n "$_prefix" ]; then
 		echo "."


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: delphij 
Responsible-Changed-When: Wed Mar 18 06:12:38 UTC 2009 
Responsible-Changed-Why:  
Looks like a useful feature, over to maintainer for review 
(note: the indentification should be changed) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132766 

From: Jilles Tjoelker <jilles@stack.nl>
To: bug-followup@FreeBSD.org, hide@koie.org
Cc:  
Subject: Re: conf/132766: wait_for_pids() in /etc/rc.subr is dull.
Date: Thu, 19 Nov 2009 23:39:38 +0100

 The new pwait(1) utility in 9-CURRENT would be an elegant approach to this.
 
 -- 
 Jilles Tjoelker
State-Changed-From-To: open->closed 
State-Changed-By: dougb 
State-Changed-When: Thu Nov 19 23:10:19 UTC 2009 
State-Changed-Why:  

I agree with Jilles, pwait will be the way this is handled going forward. 


Responsible-Changed-From-To: freebsd-rc->dougb 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Thu Nov 19 23:10:19 UTC 2009 
Responsible-Changed-Why:  

I'm closing this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132766 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/132766: commit references a PR
Date: Mon, 21 Dec 2009 22:16:20 +0000 (UTC)

 Author: jilles
 Date: Mon Dec 21 22:16:07 2009
 New Revision: 200818
 URL: http://svn.freebsd.org/changeset/base/200818
 
 Log:
   rc.subr: Use pwait in wait_for_pids.
   
   This waits for the requested process(es) to terminate, rather than polling
   with an interval of 2 seconds.
   
   If pwait is not available, the old method is used.
   
   PR:		conf/132766
   Reviewed by:	dougb
 
 Modified:
   head/etc/rc.subr
 
 Modified: head/etc/rc.subr
 ==============================================================================
 --- head/etc/rc.subr	Mon Dec 21 21:47:33 2009	(r200817)
 +++ head/etc/rc.subr	Mon Dec 21 22:16:07 2009	(r200818)
 @@ -390,7 +390,7 @@ wait_for_pids()
  		_list=$_nlist
  		echo -n ${_prefix:-"Waiting for PIDS: "}$_list
  		_prefix=", "
 -		sleep 2
 +		pwait $_list 2>/dev/null || sleep 2
  	done
  	if [ -n "$_prefix" ]; then
  		echo "."
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/132766: commit references a PR
Date: Sun, 28 Mar 2010 20:19:54 +0000 (UTC)

 Author: jilles
 Date: Sun Mar 28 20:19:41 2010
 New Revision: 205806
 URL: http://svn.freebsd.org/changeset/base/205806
 
 Log:
   MFC r200818: rc.subr: Use pwait in wait_for_pids.
   
   This waits for the requested process(es) to terminate, rather than polling
   with an interval of 2 seconds.
   
   If pwait is not available, the old method is used.
   
   PR:		conf/132766
 
 Modified:
   stable/8/etc/rc.subr
 Directory Properties:
   stable/8/etc/   (props changed)
 
 Modified: stable/8/etc/rc.subr
 ==============================================================================
 --- stable/8/etc/rc.subr	Sun Mar 28 20:09:04 2010	(r205805)
 +++ stable/8/etc/rc.subr	Sun Mar 28 20:19:41 2010	(r205806)
 @@ -390,7 +390,7 @@ wait_for_pids()
  		_list=$_nlist
  		echo -n ${_prefix:-"Waiting for PIDS: "}$_list
  		_prefix=", "
 -		sleep 2
 +		pwait $_list 2>/dev/null || sleep 2
  	done
  	if [ -n "$_prefix" ]; then
  		echo "."
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
