pkgdb: fix two issues in _update() and _release().
xbps_pkgdb_update: inverted condition that made it 'flush' when !flush. xbps_pkgdb_release: xhp->pkgdb might be NULL, but unlock pkgdb anyway.
This commit is contained in:
10
lib/pkgdb.c
10
lib/pkgdb.c
@ -125,6 +125,8 @@ ret:
|
|||||||
void
|
void
|
||||||
xbps_pkgdb_unlock(struct xbps_handle *xhp)
|
xbps_pkgdb_unlock(struct xbps_handle *xhp)
|
||||||
{
|
{
|
||||||
|
xbps_dbg_printf(xhp, "%s: pkgdb_fd %d\n", __func__, pkgdb_fd);
|
||||||
|
|
||||||
if (pkgdb_fd != -1) {
|
if (pkgdb_fd != -1) {
|
||||||
if (lockf(pkgdb_fd, F_ULOCK, 0) == -1)
|
if (lockf(pkgdb_fd, F_ULOCK, 0) == -1)
|
||||||
xbps_dbg_printf(xhp, "[pkgdb] failed to unlock pkgdb: %s\n", strerror(errno));
|
xbps_dbg_printf(xhp, "[pkgdb] failed to unlock pkgdb: %s\n", strerror(errno));
|
||||||
@ -234,7 +236,7 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush, bool update)
|
|||||||
if (cached_rv && !flush)
|
if (cached_rv && !flush)
|
||||||
return cached_rv;
|
return cached_rv;
|
||||||
|
|
||||||
if (xhp->pkgdb && update) {
|
if (xhp->pkgdb && flush) {
|
||||||
pkgdb_storage = xbps_dictionary_internalize_from_file(xhp->pkgdb_plist);
|
pkgdb_storage = xbps_dictionary_internalize_from_file(xhp->pkgdb_plist);
|
||||||
if (pkgdb_storage == NULL ||
|
if (pkgdb_storage == NULL ||
|
||||||
!xbps_dictionary_equals(xhp->pkgdb, pkgdb_storage)) {
|
!xbps_dictionary_equals(xhp->pkgdb, pkgdb_storage)) {
|
||||||
@ -276,12 +278,10 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush, bool update)
|
|||||||
void HIDDEN
|
void HIDDEN
|
||||||
xbps_pkgdb_release(struct xbps_handle *xhp)
|
xbps_pkgdb_release(struct xbps_handle *xhp)
|
||||||
{
|
{
|
||||||
assert(xhp != NULL);
|
assert(xhp);
|
||||||
|
|
||||||
if (xhp->pkgdb == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
xbps_pkgdb_unlock(xhp);
|
xbps_pkgdb_unlock(xhp);
|
||||||
|
if (xhp->pkgdb)
|
||||||
xbps_object_release(xhp->pkgdb);
|
xbps_object_release(xhp->pkgdb);
|
||||||
xbps_dbg_printf(xhp, "[pkgdb] released ok.\n");
|
xbps_dbg_printf(xhp, "[pkgdb] released ok.\n");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user