Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/handle.c
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2015-11-12 18:06:53 -0500
committerAllan McRae <allan@archlinux.org>2015-12-05 17:53:37 +1000
commit7b6f7bbe090e9c10c094c998147212ec0c1ba770 (patch)
tree948a3edd2af56381be51157c7af16eaf78b3ae37 /lib/libalpm/handle.c
parent16623a7ea577309c8cfb90920ca61342c585f73a (diff)
add and expose alpm_unlock
alpm_unlock is a limited version of alpm_release that does nothing but the actual unlinking of the lock file and is therefore safe to call from signal handlers. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/handle.c')
-rw-r--r--lib/libalpm/handle.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index b2a10c86..0d8e292a 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -126,8 +126,13 @@ int _alpm_handle_lock(alpm_handle_t *handle)
return (handle->lockfd >= 0 ? 0 : -1);
}
-/** Remove a lock file */
-int _alpm_handle_unlock(alpm_handle_t *handle)
+/** Remove the database lock file
+ * @param handle the context handle
+ * @return 0 on success, -1 on error
+ *
+ * @note Safe to call from inside signal handlers.
+ */
+int SYMEXPORT alpm_unlock(alpm_handle_t *handle)
{
ASSERT(handle->lockfile != NULL, return 0);
ASSERT(handle->lockfd >= 0, return 0);
@@ -136,6 +141,15 @@ int _alpm_handle_unlock(alpm_handle_t *handle)
handle->lockfd = -1;
if(unlink(handle->lockfile) != 0) {
+ RET_ERR(handle, ALPM_ERR_SYSTEM, -1);
+ } else {
+ return 0;
+ }
+}
+
+int _alpm_handle_unlock(alpm_handle_t *handle)
+{
+ if(alpm_unlock(handle) != 0) {
if(errno == ENOENT) {
_alpm_log(handle, ALPM_LOG_WARNING,
_("lock file missing %s\n"), handle->lockfile);
@@ -150,6 +164,7 @@ int _alpm_handle_unlock(alpm_handle_t *handle)
return -1;
}
}
+
return 0;
}