xbps_repo_close: only unlock the file lock if repo was opened as such.
If xbps_repo_open() was called with the lock arg set, xbps_repo_close() will now unlock the repo file lock, without the need to set it. This avoids the need to always unlock the file lock even if it wasn't locked previously. This also introduceds an ABI/API break, but this way it's cleaner.
This commit is contained in:
1 parent
9aaff4e2d0
commit
b23855f692
7 files changed
+18
-16
No files matched your search
+6
-4
@@ -225,10 +225,12 @@ xbps_repo_open(struct xbps_handle *xhp, const char *url, bool lock)
|
||||
/*
|
||||
* Open the repository archive.
|
||||
*/
|
||||
if (lock)
|
||||
if (lock) {
|
||||
repo->fd = open(repofile, O_RDWR);
|
||||
else
|
||||
repo->is_locked = true;
|
||||
} else {
|
||||
repo->fd = open(repofile, O_RDONLY);
|
||||
}
|
||||
|
||||
if (repo->fd == -1) {
|
||||
int rv = errno;
|
||||
@@ -252,7 +254,7 @@ out:
|
||||
}
|
||||
|
||||
void
|
||||
xbps_repo_close(struct xbps_repo *repo, bool lock)
|
||||
xbps_repo_close(struct xbps_repo *repo)
|
||||
{
|
||||
assert(repo);
|
||||
|
||||
@@ -267,7 +269,7 @@ xbps_repo_close(struct xbps_repo *repo, bool lock)
|
||||
xbps_object_release(repo->idxmeta);
|
||||
repo->idxmeta = NULL;
|
||||
}
|
||||
if (lock && lockf(repo->fd, F_ULOCK, 0) == -1)
|
||||
if (repo->is_locked && lockf(repo->fd, F_ULOCK, 0) == -1)
|
||||
xbps_dbg_printf(repo->xhp, "[repo] failed to unlock %s: %s\n", repo->uri, strerror(errno));
|
||||
|
||||
close(repo->fd);
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ xbps_rpool_release(struct xbps_handle *xhp _unused)
|
||||
|
||||
while ((repo = SIMPLEQ_FIRST(&rpool_queue))) {
|
||||
SIMPLEQ_REMOVE(&rpool_queue, repo, xbps_repo, entries);
|
||||
xbps_repo_close(repo, true);
|
||||
xbps_repo_close(repo);
|
||||
free(repo);
|
||||
}
|
||||
if (xhp->repositories)
|
||||
|
||||
Reference in new issue
Block a user