[packages/rsnapshot] - rel 6; don't delete not own lockfile if lazy option is enabled; log pid

arekm arekm at pld-linux.org
Tue Mar 10 15:15:55 CET 2015


commit 15fb5b13ff61821353cdaa4fd25834d8404a636d
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Tue Mar 10 15:15:50 2015 +0100

    - rel 6; don't delete not own lockfile if lazy option is enabled; log pid

 rsnapshot-lockfile.patch | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
 rsnapshot-pid.patch      | 38 ++++++++++++++++++++++++++++++
 rsnapshot.spec           |  6 ++++-
 3 files changed, 103 insertions(+), 1 deletion(-)
---
diff --git a/rsnapshot.spec b/rsnapshot.spec
index 92b7699..945adbd 100644
--- a/rsnapshot.spec
+++ b/rsnapshot.spec
@@ -3,12 +3,14 @@ Summary:	Program for efficient remote updates of backup sets
 Summary(pl.UTF-8):	Program do wydajnego zdalnego uaktualniania zbiorów kopii zapasowych
 Name:		rsnapshot
 Version:	1.3.1
-Release:	5
+Release:	6
 License:	GPL v2+
 Group:		Daemons
 Source0:	http://www.rsnapshot.org/downloads/%{name}-%{version}.tar.gz
 # Source0-md5:	588f92995dcf60a6ea6df8d94a017e7e
 Patch0:		%{name}-pod.patch
+Patch1:		%{name}-lockfile.patch
+Patch2:		%{name}-pid.patch
 URL:		http://www.rsnapshot.org/
 BuildRequires:	rpm-perlprov
 Requires:	rsync
@@ -24,6 +26,8 @@ w oparciu o rsynca.
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
+%patch2 -p1
 
 %build
 %configure \
diff --git a/rsnapshot-lockfile.patch b/rsnapshot-lockfile.patch
new file mode 100644
index 0000000..1a16a57
--- /dev/null
+++ b/rsnapshot-lockfile.patch
@@ -0,0 +1,60 @@
+commit 8147e706d00fb2fcd0c50e95d54b9ffcb1f56932
+Author: drhyde <drhyde>
+Date:   Tue Apr 19 15:37:28 2011 +0000
+
+    Don't delete other processes' lockfiles if use_lazy_deletes is turned on!
+    
+    Log a warning whenever deleting another process's lockfile (but only a warning, not an error, because deleting *stale* lockfiles is kosher)
+    
+    Untested
+
+diff --git a/rsnapshot-program.pl b/rsnapshot-program.pl
+index 96656ac..5ce9dbb 100755
+--- a/rsnapshot-program.pl
++++ b/rsnapshot-program.pl
+@@ -285,7 +285,10 @@ chdir($config_vars{'snapshot_root'});
+ handle_interval( $cmd );
+ 
+ # if we have a lockfile, remove it
+-remove_lockfile();
++# however, this will have already been done if use_lazy_deletes is turned
++#   on, and there may be a lockfile from another process now in place,
++#   so in that case don't just blindly delete!
++remove_lockfile() unless($use_lazy_deletes);
+ 
+ # if we got this far, the program is done running
+ # write to the log and syslog with the status of the outcome
+@@ -2278,9 +2281,12 @@ sub add_lockfile {
+ }
+ 
+ # accepts no arguments
+-# accepts the path to a lockfile and tries to remove it
+-# returns undef if lockfile isn't defined in the config file, and 1 upon success
+-# also, it can exit the program with a value of 1 if it can't remove the lockfile
++#
++# returns undef if lockfile isn't defined in the config file
++# return 1 upon success or if there's no lockfile to remove
++# warn if the PID in the lockfile is not the same as the PID of this process
++# exit with a value of 1 if it can't read the lockfile
++# exit with a value of 1 if it can't remove the lockfile
+ #
+ # we don't use bail() to exit on error, because that would call
+ # this subroutine twice in the event of a failure
+@@ -2294,6 +2300,17 @@ sub remove_lockfile {
+ 	my $result = undef;
+ 	
+ 	if ( -e "$lockfile" ) {
++	        if(open(LOCKFILE, $lockfile)) {
++		  chomp(my $locked_pid = <LOCKFILE>);
++		  close(LOCKFILE);
++		  if($locked_pid != $$) {
++		    print_warn("About to remove lockfile $lockfile which belongs to a different process (this is OK if it's a stale lock)");
++		  }
++		} else {
++		  print_err ("Could not read lockfile $lockfile: $!", 0);
++		  syslog_err("Error! Could not read lockfile $lockfile: $!");
++		  exit(1);
++		}
+ 		print_cmd("rm -f $lockfile");
+ 		if (0 == $test) {
+ 			$result = unlink($lockfile);
diff --git a/rsnapshot-pid.patch b/rsnapshot-pid.patch
new file mode 100644
index 0000000..6af1e10
--- /dev/null
+++ b/rsnapshot-pid.patch
@@ -0,0 +1,38 @@
+commit eb3b3264cd2c10720e92caf75671696859a88203
+Author: Kilburn <kilburn at la3.org>
+Date:   Sat Mar 2 11:02:49 2013 +0100
+
+    Print rnspashot's PID when logging to syslog
+    
+    Print rsnapshot's PID instead of the logger's PID when logging to
+    syslog. This is much more useful because it allow to relate log
+    lines to rsnapshot instances when there are multiple concurrent
+    ones. Previously each line had a different PID, even those
+    generated by the same instance.
+    
+    The change is achieved by dropping the "-i" option from the
+    logger's call and appending the rnapshot's PID to the tag itself.
+
+diff --git a/rsnapshot-program.pl b/rsnapshot-program.pl
+index 3d95cc2..9d9e50f 100755
+--- a/rsnapshot-program.pl
++++ b/rsnapshot-program.pl
+@@ -2098,15 +2098,15 @@ sub syslog_msg {
+ 	if (defined($config_vars{'cmd_logger'})) {
+ 		# print out our call to syslog
+ 		if (defined($verbose) && ($verbose >= 4)) {
+-			print_cmd("$config_vars{'cmd_logger'} -i -p $facility.$level -t rsnapshot $msg");
++			print_cmd("$config_vars{'cmd_logger'} -p $facility.$level -t rsnapshot[$$] $msg");
+ 		}
+ 		
+ 		# log to syslog
+ 		if (0 == $test) {
+-			$result = system($config_vars{'cmd_logger'}, '-i', '-p', "$facility.$level", '-t', 'rsnapshot', $msg);
++			$result = system($config_vars{'cmd_logger'}, '-p', "$facility.$level", '-t', "rsnapshot[$$]", $msg);
+ 			if (0 != $result) {
+ 				print_warn("Could not log to syslog:", 2);
+-				print_warn("$config_vars{'cmd_logger'} -i -p $facility.$level -t rsnapshot $msg", 2);
++				print_warn("$config_vars{'cmd_logger'} -p $facility.$level -t rsnapshot[$$] $msg", 2);
+ 			}
+ 		}
+ 	}
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rsnapshot.git/commitdiff/15fb5b13ff61821353cdaa4fd25834d8404a636d



More information about the pld-cvs-commit mailing list