Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Aug 2017 12:59:53 +0000 (UTC)
From:      Guido Falsi <madpilot@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r448520 - in head/net: asterisk11 asterisk11/files asterisk13 asterisk13/files
Message-ID:  <201708221259.v7MCxrt5096486@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: madpilot
Date: Tue Aug 22 12:59:53 2017
New Revision: 448520
URL: https://svnweb.freebsd.org/changeset/ports/448520

Log:
  Make the provided rc script more robust.
  
  Also add an asterisk_stopsleep knob (disabled by default) to allow
  users to work around a possible race condition when asterisk is sent
  a stop command just after launching, but before it's startup is
  actually completed.
  
  PR:		221271
  Submitted by:	O. Hartmann <ohartmann@walstatt.org>
  MFH:		2017Q3

Modified:
  head/net/asterisk11/Makefile
  head/net/asterisk11/files/asterisk.in
  head/net/asterisk13/Makefile
  head/net/asterisk13/files/asterisk.in

Modified: head/net/asterisk11/Makefile
==============================================================================
--- head/net/asterisk11/Makefile	Tue Aug 22 12:56:03 2017	(r448519)
+++ head/net/asterisk11/Makefile	Tue Aug 22 12:59:53 2017	(r448520)
@@ -2,7 +2,7 @@
 
 PORTNAME=	asterisk
 PORTVERSION=	11.25.1
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	net
 MASTER_SITES=	http://downloads.asterisk.org/pub/telephony/%SUBDIR%/:DEFAULT,g729
 MASTER_SITE_SUBDIR=	asterisk/ \

Modified: head/net/asterisk11/files/asterisk.in
==============================================================================
--- head/net/asterisk11/files/asterisk.in	Tue Aug 22 12:56:03 2017	(r448519)
+++ head/net/asterisk11/files/asterisk.in	Tue Aug 22 12:59:53 2017	(r448520)
@@ -17,6 +17,8 @@
 # 				Default is "-n"
 # asterisk_pidfile (string):	Location of the asterisk pid file
 #				Default is /var/run/asterisk/asterisk.pid
+# asterisk_stopsleep (int):	Number of seconds to sleep before sending stop command
+#				Default is 0, which disables it
 #
 
 . /etc/rc.subr
@@ -31,6 +33,7 @@ load_rc_config $name
 : ${asterisk_user:=%%ASTERISK_USER%%}
 : ${asterisk_args=-n}
 : ${asterisk_pidfile:=/var/run/asterisk/asterisk.pid}
+: ${asterisk_stopsleep:=0}
 
 extra_commands=reload
 
@@ -52,13 +55,26 @@ asterisk_precmd()
 
 asterisk_stop()
 {
-	echo 'Stopping asterisk'
+	if [ -z "$rc_pid" ]; then
+		[ -n "$rc_fast" ] && return 0
+		_run_rc_notrunning
+		return 1
+	fi
+	echo 'Stopping asterisk.'
+	if [ ${asterisk_stopsleep} > 0 ]; then
+		sleep ${asterisk_stopsleep}
+	fi
 	$command -nqrx 'core stop now'
+	wait_for_pids $rc_pid
 }
 
 asterisk_reload()
 {
-	echo 'Reloading asterisk'
+	if [ -z "$rc_pid" ]; then
+		_run_rc_notrunning
+		return 1
+	fi
+	echo 'Reloading asterisk.'
 	$command -nqrx 'reload'
 }
 

Modified: head/net/asterisk13/Makefile
==============================================================================
--- head/net/asterisk13/Makefile	Tue Aug 22 12:56:03 2017	(r448519)
+++ head/net/asterisk13/Makefile	Tue Aug 22 12:59:53 2017	(r448520)
@@ -2,6 +2,7 @@
 
 PORTNAME=	asterisk
 PORTVERSION=	13.17.0
+PORTREVISION=	1
 CATEGORIES=	net
 MASTER_SITES=	http://downloads.asterisk.org/pub/telephony/%SUBDIR%/:DEFAULT,g729
 MASTER_SITE_SUBDIR=	asterisk/ \

Modified: head/net/asterisk13/files/asterisk.in
==============================================================================
--- head/net/asterisk13/files/asterisk.in	Tue Aug 22 12:56:03 2017	(r448519)
+++ head/net/asterisk13/files/asterisk.in	Tue Aug 22 12:59:53 2017	(r448520)
@@ -17,6 +17,8 @@
 # 				Default is "-n"
 # asterisk_pidfile (string):	Location of the asterisk pid file
 #				Default is /var/run/asterisk/asterisk.pid
+# asterisk_stopsleep (int):	Number of seconds to sleep before sending stop command
+#				Default is 0, which disables it
 #
 
 . /etc/rc.subr
@@ -31,6 +33,7 @@ load_rc_config $name
 : ${asterisk_user:=%%ASTERISK_USER%%}
 : ${asterisk_args=-n}
 : ${asterisk_pidfile:=/var/run/asterisk/asterisk.pid}
+: ${asterisk_stopsleep:=0}
 
 extra_commands=reload
 
@@ -52,13 +55,26 @@ asterisk_precmd()
 
 asterisk_stop()
 {
-	echo 'Stopping asterisk'
+	if [ -z "$rc_pid" ]; then
+		[ -n "$rc_fast" ] && return 0
+		_run_rc_notrunning
+		return 1
+	fi
+	echo 'Stopping asterisk.'
+	if [ ${asterisk_stopsleep} > 0 ]; then
+		sleep ${asterisk_stopsleep}
+	fi
 	$command -nqrx 'core stop now'
+	wait_for_pids $rc_pid
 }
 
 asterisk_reload()
 {
-	echo 'Reloading asterisk'
+	if [ -z "$rc_pid" ]; then
+		_run_rc_notrunning
+		return 1
+	fi
+	echo 'Reloading asterisk.'
 	$command -nqrx 'reload'
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708221259.v7MCxrt5096486>