Track packages using a lifetime unique identifier

Use that identifier to cancel graph edges rather than the number of hits,
which biases the earliest edge rather than the latest.
Ariadne Conill 2023-08-04 08:19:42 +00:00
parent 437c2a3218
commit 5d0e2f5092
3 changed files with 6 additions and 6 deletions

View File

@ -167,8 +167,7 @@ struct pkgconf_pkg_ {
pkgconf_tuple_t *prefix;
uint64_t serial;
size_t hits;
uint64_t identifier;
};
typedef bool (*pkgconf_pkg_iteration_func_t)(const pkgconf_pkg_t *pkg, void *data);
@ -204,6 +203,7 @@ struct pkgconf_client_ {
bool already_sent_notice;
uint64_t serial;
uint64_t identifier;
pkgconf_pkg_t **cache_table;
size_t cache_count;

View File

@ -1494,7 +1494,7 @@ pkgconf_pkg_walk_list(pkgconf_client_t *client,
if (pkgdep->serial == client->serial && !(parent->flags & PKGCONF_PKG_PROPF_VIRTUAL))
{
pkgdep->hits++;
pkgdep->identifier = ++client->identifier;
/* In this case we have a circular reference.
* We break that by deleteing the circular node from the
@ -1523,7 +1523,7 @@ pkgconf_pkg_walk_list(pkgconf_client_t *client,
pkgconf_audit_log_dependency(client, pkgdep, depnode);
pkgdep->hits++;
pkgdep->identifier = ++client->identifier;
pkgdep->serial = client->serial;
eflags |= pkgconf_pkg_traverse_main(client, pkgdep, func, data, depth - 1, skip_flags);
next:

View File

@ -144,7 +144,7 @@ dep_sort_cmp(const void *a, const void *b)
const pkgconf_dependency_t *depA = *(void **) a;
const pkgconf_dependency_t *depB = *(void **) b;
return depB->match->hits - depA->match->hits;
return depB->match->identifier - depA->match->identifier;
}
static inline void
@ -219,7 +219,7 @@ next:
memset(&dep->iter, '\0', sizeof (dep->iter));
pkgconf_node_insert(&dep->iter, dep, list);
PKGCONF_TRACE(client, "slot "SIZE_FMT_SPECIFIER": dep %s matched to %p<%s> hits "SIZE_FMT_SPECIFIER, i, dep->package, dep->match, dep->match->id, dep->match->hits);
PKGCONF_TRACE(client, "slot "SIZE_FMT_SPECIFIER": dep %s matched to %p<%s> id "SIZE_FMT_SPECIFIER, i, dep->package, dep->match, dep->match->id, dep->match->identifier);
}
free(deps);