Skip to content

Commit 242513b

Browse files
committed
lib/pkgdb.c: warn if the pkgdb is locked and its waiting
1 parent 5b90965 commit 242513b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/pkgdb.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,14 @@ xbps_pkgdb_lock(struct xbps_handle *xhp)
108108
}
109109
umask(prev_umask);
110110

111+
if (flock(xhp->lock_fd, LOCK_EX|LOCK_NB) == -1) {
112+
if (errno != EWOULDBLOCK)
113+
goto err;
114+
xbps_warn_printf("package database locked, waiting...\n");
115+
}
116+
111117
if (flock(xhp->lock_fd, LOCK_EX) == -1) {
118+
err:
112119
close(xhp->lock_fd);
113120
xhp->lock_fd = -1;
114121
return xbps_error_errno(errno, "failed to lock file: %s: %s\n",

0 commit comments

Comments
 (0)