[pacman-dev] [PATCH 07/11] handle_unlock: log lock removal failure

Andrew Gregory andrew.gregory.8 at gmail.com
Fri Aug 1 17:19:50 EDT 2014


Rather than have individual callers log failure, just
do it directly in _alpm_handle_unlock.

Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
---
 lib/libalpm/be_sync.c | 6 +-----
 lib/libalpm/handle.c  | 4 ++++
 lib/libalpm/trans.c   | 7 +------
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index df0b1b7..4b67f42 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -291,11 +291,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
 	}
 
 cleanup:
-
-	if(_alpm_handle_unlock(handle)) {
-		_alpm_log(handle, ALPM_LOG_WARNING, _("could not remove lock file %s\n"),
-				handle->lockfile);
-	}
+	_alpm_handle_unlock(handle);
 	free(syncpath);
 	umask(oldmask);
 	return ret;
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index b218a68..234fc4d 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -126,6 +126,10 @@ int _alpm_handle_unlock(alpm_handle_t *handle)
 	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;
 	}
 	return 0;
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index e5328c5..68f6633 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -231,12 +231,7 @@ int SYMEXPORT alpm_trans_release(alpm_handle_t *handle)
 
 	/* unlock db */
 	if(!nolock_flag) {
-		if(_alpm_handle_unlock(handle)) {
-			_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);
-		}
+		_alpm_handle_unlock(handle);
 	}
 
 	return 0;
-- 
2.0.2


More information about the pacman-dev mailing list