Added lock check before unlocking

This commit is contained in:
deajan 2016-07-27 12:04:27 +02:00
parent e685da33fa
commit 166f67bb55
1 changed files with 17 additions and 4 deletions

View File

@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2016 by Orsiris de Jong" AUTHOR="(C) 2013-2016 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION=1.1.1-dev PROGRAM_VERSION=1.1.1-dev
PROGRAM_BUILD=2016072702 PROGRAM_BUILD=2016072703
IS_STABLE=yes IS_STABLE=yes
source "./ofunctions.sh" source "./ofunctions.sh"
@ -309,6 +309,7 @@ function _WriteLockFilesLocal {
exit 1 exit 1
else else
Logger "Locked replica on [$lockfile]." "DEBUG" Logger "Locked replica on [$lockfile]." "DEBUG"
LOCK_LOCAL=1
fi fi
} }
@ -330,6 +331,7 @@ function _WriteLockFilesRemote {
exit 1 exit 1
else else
Logger "Locked remote target replica." "DEBUG" Logger "Locked remote target replica." "DEBUG"
LOCK_REMOTE_1
fi fi
} }
@ -483,11 +485,18 @@ function UnlockReplicas {
return 0 return 0
fi fi
_UnlockReplicasLocal "${INITIATOR[2]}" if [ $LOCK_LOCAL -eq 1 ]; then
_UnlockReplicasLocal "${INITIATOR[2]}"
fi
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != "yes" ]; then
_UnlockReplicasLocal "${TARGET[2]}" if [ $LOCK_LOCAL -eq 1 ]; then
_UnlockReplicasLocal "${TARGET[2]}"
fi
else else
_UnlockReplicasRemote "${TARGET[2]}" if [ $LOCK_REMOTE -eq 1 ]; then
_UnlockReplicasRemote "${TARGET[2]}"
fi
fi fi
} }
@ -1591,6 +1600,10 @@ PARTIAL=0
if [ "$CONFLICT_PREVALANCE" == "" ]; then if [ "$CONFLICT_PREVALANCE" == "" ]; then
CONFLICT_PREVALANCE=initiator CONFLICT_PREVALANCE=initiator
fi fi
LOCK_LOCAL=0
LOCK_REMOTE=0
FORCE_UNLOCK=0 FORCE_UNLOCK=0
no_maxtime=0 no_maxtime=0
opts="" opts=""