mirror of
https://github.com/moparisthebest/pacman
synced 2025-03-11 07:31:04 -04:00
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>
This commit is contained in:
parent
16623a7ea5
commit
7b6f7bbe09
@ -1559,6 +1559,7 @@ char *alpm_compute_sha256sum(const char *filename);
|
|||||||
alpm_handle_t *alpm_initialize(const char *root, const char *dbpath,
|
alpm_handle_t *alpm_initialize(const char *root, const char *dbpath,
|
||||||
alpm_errno_t *err);
|
alpm_errno_t *err);
|
||||||
int alpm_release(alpm_handle_t *handle);
|
int alpm_release(alpm_handle_t *handle);
|
||||||
|
int alpm_unlock(alpm_handle_t *handle);
|
||||||
|
|
||||||
enum alpm_caps {
|
enum alpm_caps {
|
||||||
ALPM_CAPABILITY_NLS = (1 << 0),
|
ALPM_CAPABILITY_NLS = (1 << 0),
|
||||||
|
@ -126,8 +126,13 @@ int _alpm_handle_lock(alpm_handle_t *handle)
|
|||||||
return (handle->lockfd >= 0 ? 0 : -1);
|
return (handle->lockfd >= 0 ? 0 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove a lock file */
|
/** Remove the database lock file
|
||||||
int _alpm_handle_unlock(alpm_handle_t *handle)
|
* @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->lockfile != NULL, return 0);
|
||||||
ASSERT(handle->lockfd >= 0, return 0);
|
ASSERT(handle->lockfd >= 0, return 0);
|
||||||
@ -136,6 +141,15 @@ int _alpm_handle_unlock(alpm_handle_t *handle)
|
|||||||
handle->lockfd = -1;
|
handle->lockfd = -1;
|
||||||
|
|
||||||
if(unlink(handle->lockfile) != 0) {
|
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) {
|
if(errno == ENOENT) {
|
||||||
_alpm_log(handle, ALPM_LOG_WARNING,
|
_alpm_log(handle, ALPM_LOG_WARNING,
|
||||||
_("lock file missing %s\n"), handle->lockfile);
|
_("lock file missing %s\n"), handle->lockfile);
|
||||||
@ -150,6 +164,7 @@ int _alpm_handle_unlock(alpm_handle_t *handle)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user