rpool: miscellaneous improvements to _init() and _release().
xbps_repository_pool_init: - Avoid unnecessary extra access(2) syscall when internalizing repository index plist files. xbps_repository_pool_release: - Make sure to release internalized repository index arrays.
This commit is contained in:
parent
bfe7ab1c5a
commit
53d28fcb35
@ -101,10 +101,11 @@ xbps_repository_pool_init(struct xbps_handle *xhp)
|
|||||||
rv = errno;
|
rv = errno;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (access(plist, R_OK) == -1) {
|
array = prop_array_internalize_from_zfile(plist);
|
||||||
xbps_dbg_printf("[rpool] `%s' missing index "
|
|
||||||
"file, ignoring.\n", repouri);
|
|
||||||
free(plist);
|
free(plist);
|
||||||
|
if (array == NULL) {
|
||||||
|
xbps_dbg_printf("[rpool] `%s' cannot be internalized:"
|
||||||
|
" %s\n", repouri, strerror(errno));
|
||||||
nmissing++;
|
nmissing++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -114,23 +115,15 @@ xbps_repository_pool_init(struct xbps_handle *xhp)
|
|||||||
d = prop_dictionary_create();
|
d = prop_dictionary_create();
|
||||||
if (d == NULL) {
|
if (d == NULL) {
|
||||||
rv = ENOMEM;
|
rv = ENOMEM;
|
||||||
free(plist);
|
prop_object_release(array);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!prop_dictionary_set_cstring_nocopy(d, "uri", repouri)) {
|
if (!prop_dictionary_set_cstring_nocopy(d, "uri", repouri)) {
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
|
prop_object_release(array);
|
||||||
prop_object_release(d);
|
prop_object_release(d);
|
||||||
free(plist);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
array = prop_array_internalize_from_zfile(plist);
|
|
||||||
if (array == NULL) {
|
|
||||||
rv = EINVAL;
|
|
||||||
prop_object_release(d);
|
|
||||||
free(plist);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
free(plist);
|
|
||||||
prop_array_make_immutable(array);
|
prop_array_make_immutable(array);
|
||||||
if (!xbps_add_obj_to_dict(d, array, "index")) {
|
if (!xbps_add_obj_to_dict(d, array, "index")) {
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
@ -162,6 +155,7 @@ out:
|
|||||||
void HIDDEN
|
void HIDDEN
|
||||||
xbps_repository_pool_release(struct xbps_handle *xhp)
|
xbps_repository_pool_release(struct xbps_handle *xhp)
|
||||||
{
|
{
|
||||||
|
prop_array_t idx;
|
||||||
prop_dictionary_t d;
|
prop_dictionary_t d;
|
||||||
size_t i;
|
size_t i;
|
||||||
const char *uri;
|
const char *uri;
|
||||||
@ -171,11 +165,12 @@ xbps_repository_pool_release(struct xbps_handle *xhp)
|
|||||||
|
|
||||||
for (i = 0; i < prop_array_count(xhp->repo_pool); i++) {
|
for (i = 0; i < prop_array_count(xhp->repo_pool); i++) {
|
||||||
d = prop_array_get(xhp->repo_pool, i);
|
d = prop_array_get(xhp->repo_pool, i);
|
||||||
|
idx = prop_dictionary_get(d, "index");
|
||||||
prop_dictionary_get_cstring_nocopy(d, "uri", &uri);
|
prop_dictionary_get_cstring_nocopy(d, "uri", &uri);
|
||||||
xbps_dbg_printf("[rpool] unregistered repository '%s'\n", uri);
|
xbps_dbg_printf("[rpool] unregistered repository '%s'\n", uri);
|
||||||
|
prop_object_release(idx);
|
||||||
prop_object_release(d);
|
prop_object_release(d);
|
||||||
}
|
}
|
||||||
prop_object_release(xhp->repo_pool);
|
|
||||||
xhp->repo_pool = NULL;
|
xhp->repo_pool = NULL;
|
||||||
xbps_dbg_printf("[rpool] released ok.\n");
|
xbps_dbg_printf("[rpool] released ok.\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user