From 0bf4ae726d6a98142a176b9ac0b9ed8f00389e67 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Fri, 1 Aug 2014 14:19:51 -0700 Subject: handle_unlock: log error when lock file is missing Problems due to concurrent running instances of pacman can be difficult to diagnose. Log a warning to make it more obvious that that's what happened, that it's a bad idea, and hopefully encourage people who do things like removing the lock file to run pacman from an install script to at least be courteous enough to put it back when they're done. Signed-off-by: Andrew Gregory Signed-off-by: Allan McRae --- lib/libalpm/handle.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index 234fc4d0..0efc0a96 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -125,12 +125,20 @@ int _alpm_handle_unlock(alpm_handle_t *handle) close(handle->lockfd); handle->lockfd = -1; - if(unlink(handle->lockfile) && errno != ENOENT) { - _alpm_log(handle, ALPM_LOG_WARNING, - _("could not remove lock file %s\n"), handle->lockfile); - alpm_logaction(handle, ALPM_CALLER_PREFIX, - "warning: could not remove lock file %s\n", handle->lockfile); - return -1; + if(unlink(handle->lockfile) != 0) { + if(errno == ENOENT) { + _alpm_log(handle, ALPM_LOG_WARNING, + _("lock file missing %s\n"), handle->lockfile); + alpm_logaction(handle, ALPM_CALLER_PREFIX, + "warning: lock file missing %s\n", handle->lockfile); + return 0; + } else { + _alpm_log(handle, ALPM_LOG_WARNING, + _("could not remove lock file %s\n"), handle->lockfile); + alpm_logaction(handle, ALPM_CALLER_PREFIX, + "warning: could not remove lock file %s\n", handle->lockfile); + return -1; + } } return 0; } -- cgit v1.2.3-70-g09d2