mirror of
https://github.com/openbsd/src.git
synced 2026-06-18 07:13:36 +02:00
Move repo_tree_free() up to where the other repo functions live.
OK tb@
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: parser.c,v 1.178 2026/01/27 09:41:42 tb Exp $ */
|
||||
/* $OpenBSD: parser.c,v 1.179 2026/04/23 14:15:53 claudio Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
|
||||
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
@@ -108,6 +108,26 @@ repo_add(unsigned int id, char *path, char *validpath)
|
||||
errx(1, "pthread_rwlock_unlock: %s", strerror(error));
|
||||
}
|
||||
|
||||
static void
|
||||
repo_tree_free(struct repo_tree *tree)
|
||||
{
|
||||
struct parse_repo *repo, *trepo;
|
||||
int error;
|
||||
|
||||
if ((error = pthread_rwlock_wrlock(&repos_lk)) != 0)
|
||||
errx(1, "pthread_rwlock_wrlock: %s", strerror(error));
|
||||
RB_FOREACH_SAFE(repo, repo_tree, tree, trepo) {
|
||||
RB_REMOVE(repo_tree, tree, repo);
|
||||
free(repo->path);
|
||||
free(repo->validpath);
|
||||
free(repo);
|
||||
}
|
||||
if ((error = pthread_rwlock_unlock(&repos_lk)) != 0)
|
||||
errx(1, "pthread_rwlock_unlock: %s", strerror(error));
|
||||
if ((error = pthread_rwlock_destroy(&repos_lk)) != 0)
|
||||
errx(1, "pthread_rwlock_destroy: %s", strerror(error));
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the issuer by its certificate id, or NULL on failure.
|
||||
* Make sure the AKI is the same as the AKI listed on the Manifest,
|
||||
@@ -1151,26 +1171,6 @@ parse_writer(void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
repo_tree_free(struct repo_tree *tree)
|
||||
{
|
||||
struct parse_repo *repo, *trepo;
|
||||
int error;
|
||||
|
||||
if ((error = pthread_rwlock_wrlock(&repos_lk)) != 0)
|
||||
errx(1, "pthread_rwlock_wrlock: %s", strerror(error));
|
||||
RB_FOREACH_SAFE(repo, repo_tree, tree, trepo) {
|
||||
RB_REMOVE(repo_tree, tree, repo);
|
||||
free(repo->path);
|
||||
free(repo->validpath);
|
||||
free(repo);
|
||||
}
|
||||
if ((error = pthread_rwlock_unlock(&repos_lk)) != 0)
|
||||
errx(1, "pthread_rwlock_unlock: %s", strerror(error));
|
||||
if ((error = pthread_rwlock_destroy(&repos_lk)) != 0)
|
||||
errx(1, "pthread_rwlock_destroy: %s", strerror(error));
|
||||
}
|
||||
|
||||
/*
|
||||
* Process responsible for parsing and validating content.
|
||||
* All this process does is wait to be told about a file to parse, then
|
||||
|
||||
Reference in New Issue
Block a user