Acquire/release a POSIX file lock on repository archives.

- xbps_repo_open() accepts a third argument (bool) to acquire a POSIX file
lock on the repository archive.
- xbps_repo_close() accepts a second argument (bool) to release a POSIX file
lock on the repository archive.

This avoids the issue of multiple xbps-rindex(8) processes being blocked
even for different repositories on the same architecture, resulting in
unnecessary contention.
This commit is contained in:
Juan RP
2014-09-05 12:26:42 +02:00
parent 551555690d
commit 013731c502
13 changed files with 70 additions and 174 deletions

View File

@@ -117,7 +117,7 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
char *ext;
int rv = 0;
repo = xbps_repo_open(xhp, repodir);
repo = xbps_repo_open(xhp, repodir, false);
if (repo == NULL) {
if (errno != ENOENT) {
fprintf(stderr, "xbps-rindex: cannot read repository data: %s\n",
@@ -151,7 +151,7 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
(void)closedir(dirp);
rv = xbps_array_foreach_cb_multi(xhp, array, NULL, cleaner_cb, repo);
xbps_repo_close(repo);
xbps_repo_close(repo, false);
xbps_object_release(array);
return rv;