From 20c4b654ba9a5027f59d7063b5a364ff0f370bd1 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 2 Sep 2016 13:52:25 +0200 Subject: [PATCH] Log better errors when locks could not be acquired Signed-off-by: Michael Tremer --- src/functions/functions.lock | 7 ++++++- src/udev/network-hotplug-rename | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/functions/functions.lock b/src/functions/functions.lock index b09b0b3..99da1f9 100644 --- a/src/functions/functions.lock +++ b/src/functions/functions.lock @@ -40,7 +40,12 @@ lock_acquire() { sleep 0.25 done - assert ${free} "Could not acquire lock '${lockfile}'" + if ! ${free}; then + log ERROR "Could not acquire lock '${lockfile}'" + return ${EXIT_ERROR} + fi + + assert [ ! -e "${lockfile}" ] # Write out pid to the lockfile and make sure that # nobody else can access it. diff --git a/src/udev/network-hotplug-rename b/src/udev/network-hotplug-rename index c56c70d..0b50018 100644 --- a/src/udev/network-hotplug-rename +++ b/src/udev/network-hotplug-rename @@ -45,7 +45,7 @@ log DEBUG "Called for interface '${INTERFACE}'." device_exists ${INTERFACE} || exit ${EXIT_ERROR} # Acquiring lock for this operation. -lock_acquire ${LOCKFILE} +lock_acquire ${LOCKFILE} || exit ${EXIT_ERROR} # Check if the device is already in use and # prevent the script to touch it in any way. -- 2.47.3