Commit 3df27278 authored by bescoto's avatar bescoto

Abort if another rdiff-backup is processing same dir


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@709 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent e6698c92
......@@ -3,6 +3,9 @@ New in v1.1.5 (????/??/??)
Fix for restoring files in directories with really long names.
rdiff-backup will now exit by default if it thinks another
rdiff-backup process is currently working on the same repository.
New in v1.1.4 (2005/12/13)
--------------------------
......
......@@ -801,6 +801,7 @@ information in it.
""" % (Globals.rbdir.path,))
elif len(curmir_incs) == 1: return 0
else:
if not force: curmir_incs[0].conn.regress.check_pids(curmir_incs)
assert len(curmir_incs) == 2, "Found too many current_mirror incs!"
return 1
......
......@@ -34,6 +34,7 @@ be recovered.
"""
from __future__ import generators
import signal, errno, re, os
import Globals, restore, log, rorpiter, TempFile, metadata, rpath, C, \
Time, backup, robust, longname
......@@ -328,3 +329,31 @@ class RegressITRB(rorpiter.ITRBranch):
if rf.regress_inc:
log.Log("Deleting increment " + rf.regress_inc.path, 5)
rf.regress_inc.delete()
def check_pids(curmir_incs):
"""Check PIDs in curmir markers to make sure rdiff-backup not running"""
pid_re = re.compile("^PID\s*([0-9]+)", re.I | re.M)
def extract_pid(curmir_rp):
"""Return process ID from a current mirror marker, if any"""
match = pid_re.search(curmir_rp.get_data())
if not match: return None
else: return int(match.group(1))
def pid_running(pid):
"""True if we know if process with pid is currently running"""
try: os.kill(pid, signal.NSIG)
except OSError, exc:
if exc[0] == errno.ESRCH: return 0
elif exc[0] == errno.EINVAL: return 1
Log("Warning: unable to check if PID %d still running" % (pid,), 2)
for curmir_rp in curmir_incs:
assert Globals.local_connection is curmir_rp.conn
pid = extract_pid(curmir_rp)
if pid is not None and pid_running(pid):
log.Log.FatalError(
"""It appears that a previous rdiff-backup session with process id
%d is still running. To proceed with regress, rerun rdiff-backup with the
--force option.""" % (pid,))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment