summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2014-08-01 14:19:51 -0700
committerAllan McRae <allan@archlinux.org>2014-08-04 14:23:58 +1000
commit0bf4ae726d6a98142a176b9ac0b9ed8f00389e67 (patch)
tree27960cde838d1dc649bdc30c3457408ff3c232d8 /lib/libalpm
parent03b9bf08ac3b1e3f2c3b950ce995654af2c40503 (diff)
downloadpacman-0bf4ae726d6a98142a176b9ac0b9ed8f00389e67.tar.xz
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 <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/handle.c20
1 files changed, 14 insertions, 6 deletions
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;
}