[Git][pkg-voip-team/asterisk][experimental-16] 2 commits: Improve/fix some raceconditions in sysv-initscript

Bernhard Schmidt gitlab at salsa.debian.org
Fri Jan 11 17:38:52 GMT 2019


Bernhard Schmidt pushed to branch experimental-16 at Debian VoIP Packaging Team / asterisk


Commits:
06858751 by Bernhard Schmidt at 2019-01-04T15:09:11Z
Improve/fix some raceconditions in sysv-initscript

Thanks: Walter Doekes
Closes: #778746

- - - - -
dbac7f59 by Bernhard Schmidt at 2019-01-04T15:21:18Z
Changelog for 1:16.1.0~dfsg-4

- - - - -


2 changed files:

- debian/asterisk.init
- debian/changelog


Changes:

=====================================
debian/asterisk.init
=====================================
@@ -118,6 +118,10 @@ status() {
 	status_of_proc -p "$PIDFILE" "$NAME" "$DESC" && return 0 || return $?
 }
 
+safe_status() {
+	status_of_proc -p "$ASTSAFE_PIDFILE" "$NAME" "$DESC" && return 0 || return $?
+}
+
 asterisk_rx() {
 	if ! status >/dev/null; then return 0; fi
 
@@ -139,46 +143,53 @@ case "$1" in
 	exit 0
 	;;
   start)
-	if status > /dev/null; then
-		echo "$DESC is already running. Use restart."
-		exit 0
-	fi
-	echo -n "Starting $DESC: "
-	if [ "$RUNASTSAFE" != "yes" ];then
-		# TODO: what if we cought the wrapper just as its asterisk
-		# was killed? status should check for the wrapper if we're in
-		# "safe mode"
-		if status > /dev/null; then
+	if [ "$RUNASTSAFE" = "yes" ];then
+		if safe_status >/dev/null; then
 			echo "$DESC is already running. Use restart."
 			exit 0
 		fi
-		start-stop-daemon --start --group $GROUP --pidfile "$PIDFILE" \
-			$CHDIR_PARM \
-			--exec $REALDAEMON -- $PARAMS > /dev/null
-	else
+		echo -n "Starting $DESC: "
 		export ASTSAFE_FOREGROUND=1
 		start-stop-daemon --start --group $GROUP \
 			--background --make-pidfile \
 			$CHDIR_PARM --pidfile "$ASTSAFE_PIDFILE" \
 			--exec $REALDAEMON -- $PARAMS
+	else
+		if status >/dev/null; then
+			echo "$DESC is already running. Use restart."
+			exit 0
+		fi
+		echo -n "Starting $DESC: "
+		start-stop-daemon --start --group $GROUP --pidfile "$PIDFILE" \
+			$CHDIR_PARM \
+			--exec $REALDAEMON -- $PARAMS > /dev/null
 	fi
-		
-	
 	echo "$NAME."
 	;;
   stop)
 	echo -n "Stopping $DESC: $NAME"
 	# Try gracefully.
-	# this may hang in some cases. Specifically, when the asterisk
+	# This may hang in some cases. Specifically, when the asterisk
 	# processes is stopped. No bother to worry about cleanup: 
 	# it will either fail or die when asterisk dies.
 	( asterisk_rx 'core stop now' > /dev/null 2>&1 & ) &
 	if [ "$RUNASTSAFE" = "yes" ];then
+		# If you're switching back and forth between RUNASTSAFE
+		# you may get a warning about a stale pidfile. Ignore
+		# it.
 		start-stop-daemon --stop --quiet --oknodo \
 				  --pidfile $ASTSAFE_PIDFILE
 		rm -f $ASTSAFE_PIDFILE
 	fi
-	start-stop-daemon --stop --quiet --oknodo --exec $DAEMON --pidfile=$PIDFILE
+	# Sometimes during a quick restart cycle, the 'core stop now'
+	# from above won't reach the daemon -- perhaps it wasn't
+	# listening yet. At this point we want TERM to kick in.
+	# In any case, we must be certain that it is stopped before we
+	# exit the "stop" case; otherwise a "restart" might complete
+	# with no asterisk running at all (because of the status checks
+	# in "start").
+	start-stop-daemon --stop --quiet --oknodo --retry=8/TERM/30/KILL/5 \
+		--exec $DAEMON --pidfile=$PIDFILE
 	echo "."
 	;;
   reload)


=====================================
debian/changelog
=====================================
@@ -1,3 +1,19 @@
+asterisk (1:16.1.0~dfsg-4) experimental; urgency=medium
+
+  * Update build-deps
+    - Revert mariadb-10.3 change, not necessary anymore
+    - Add libsnmp-dev again, works now
+    - Add libosptk-dev for Open Settlement Protocol, see Bug#786973.
+      Not sure yet whether we will keep this for unstable.
+    - Drop libsqlite0-dev, deprecated
+  * Do not load any local channel drivers by default (see #821392)
+  * asterisk.service: Attempt to run with realtime priority by default
+    (see #801629)
+  * Improve/fix some race-conditions in sysv-initscript.
+    Thanks to Walter Doekes (see #778746)
+
+ -- Bernhard Schmidt <berni at debian.org>  Fri, 04 Jan 2019 16:00:17 +0100
+
 asterisk (1:16.1.0~dfsg-3) experimental; urgency=medium
 
   * Adjust MySQL build-dep for current mariadb-10.3 breakage



View it on GitLab: https://salsa.debian.org/pkg-voip-team/asterisk/compare/f2de8de92cbe34b839dec68c430eb5448d9794c2...dbac7f59c6fc4f6ccf4ea2649e76e12e2e33307a

-- 
View it on GitLab: https://salsa.debian.org/pkg-voip-team/asterisk/compare/f2de8de92cbe34b839dec68c430eb5448d9794c2...dbac7f59c6fc4f6ccf4ea2649e76e12e2e33307a
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-voip-maintainers/attachments/20190111/6cb38435/attachment-0001.html>


More information about the Pkg-voip-maintainers mailing list