[packages/php-dirs] revert 37fa3e2, gc_time is not dependant on cleaned up dir

glen glen at pld-linux.org
Thu Dec 11 14:20:53 CET 2014


commit 3bb55b26f848024e7e80cbc8f7c081a89b7c5206
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Thu Dec 11 15:18:42 2014 +0200

    revert 37fa3e2, gc_time is not dependant on cleaned up dir
    
    add function for readability

 php-session.sh | 46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)
---
diff --git a/php-session.sh b/php-session.sh
index a12c1a6..81f90bc 100755
--- a/php-session.sh
+++ b/php-session.sh
@@ -2,28 +2,12 @@
 
 [ -x /usr/sbin/tmpwatch ] || exit 0
 
-for session_dir in /var/run/php /var/run/php-ug; do
-	[ ! -d "$session_dir" ] && continue
-
-	# find minimum gc time from any of the php engines
-	gc_time=0
-	for php in php php4 php52 php53 php54 php55; do
-		gc=
-		if [ -x /usr/bin/$php ]; then
-			gc=$($php -r 'echo max(round(ini_get("session.gc_maxlifetime")/3600), 1);' 2> /dev/null)
-		elif [ -r /etc/$php/php.ini ]; then
-			gc=$(awk -F"=" '/^session.gc_maxlifetime[ \t]*=/ { t=sprintf("%d", ($2/3600)); if (t<1) { t=1; }; print t; exit;}' /etc/$php/php.ini)
-		fi
-		[ -n "$gc" ] || continue
-
-		if [ "$gc" -lt "$gc_time" ] || [ $gc_time -eq 0 ]; then
-			gc_time=$gc
-		fi
-	done
+session_dirs="/var/run/php /var/run/php-ug"
 
-	[ $gc_time -gt 0 ] || continue
+# use tmpwatch with --test to remove only files matching to 'sess_*' pattern
+cleanup_dir() {
+	local session_dir=$1
 
-	# use tmpwatch with --test to remove only files matching to 'sess_*' pattern
 	/usr/sbin/tmpwatch $gc_time $session_dir --test | while read action type file; do
 		case "$action $type $file" in
 		'removing file '*/sess_*)
@@ -31,4 +15,26 @@ for session_dir in /var/run/php /var/run/php-ug; do
 			;;
 		esac
 	done
+}
+
+# find minimum gc time from any of the php engines
+gc_time=0
+for php in php php4 php52 php53 php54 php55; do
+	gc=
+	if [ -x /usr/bin/$php ]; then
+		gc=$($php -r 'echo max(round(ini_get("session.gc_maxlifetime")/3600), 1);' 2> /dev/null)
+	elif [ -r /etc/$php/php.ini ]; then
+		gc=$(awk -F"=" '/^session.gc_maxlifetime[ \t]*=/ { t=sprintf("%d", ($2/3600)); if (t<1) { t=1; }; print t; exit;}' /etc/$php/php.ini)
+	fi
+	[ -n "$gc" ] || continue
+
+	if [ "$gc" -lt "$gc_time" ] || [ $gc_time -eq 0 ]; then
+		gc_time=$gc
+	fi
+done
+
+[ $gc_time -gt 0 ] || exit 0
+
+for session_dir in $session_dirs; do
+	cleanup_dir $session_dir
 done
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/php-dirs.git/commitdiff/c2fd47f2430f6e1c9de8df01d4fbd81610086238



More information about the pld-cvs-commit mailing list