Commit 0692a290 authored by Nils Goroll's avatar Nils Goroll
parent 56c6ebb9
...@@ -48,7 +48,7 @@ static vre_t *chars = NULL, *dots = NULL, *stars = NULL, *meta = NULL; ...@@ -48,7 +48,7 @@ static vre_t *chars = NULL, *dots = NULL, *stars = NULL, *meta = NULL;
* else if A is shorter than B * else if A is shorter than B
* else if strcmp(A, B) < 0. * else if strcmp(A, B) < 0.
* *
* VRB_FIND and VRB_INSERT are only called during vcl_init, so the * VRBT_FIND and VRBT_INSERT are only called during vcl_init, so the
* comparator is not on the critical performance path. * comparator is not on the critical performance path.
*/ */
int int
...@@ -108,7 +108,7 @@ path_cmp(const struct assignment * restrict const ass_a, ...@@ -108,7 +108,7 @@ path_cmp(const struct assignment * restrict const ass_a,
return cmp; return cmp;
} }
VRB_GENERATE(assign_tree, assignment, entry, path_cmp) VRBT_GENERATE(assign_tree, assignment, entry, path_cmp)
void void
validation_init(void) validation_init(void)
......
...@@ -284,7 +284,7 @@ vmod_hosts__fini(struct vmod_hoailona_hosts **hostsp) ...@@ -284,7 +284,7 @@ vmod_hosts__fini(struct vmod_hoailona_hosts **hostsp)
free(host->name); free(host->name);
if (host->description != NULL) if (host->description != NULL)
free(host->description); free(host->description);
a = VRB_MIN(assign_tree, &host->assignments); a = VRBT_MIN(assign_tree, &host->assignments);
while (a != NULL) { while (a != NULL) {
struct assignment *next_ass; struct assignment *next_ass;
...@@ -299,7 +299,7 @@ vmod_hosts__fini(struct vmod_hoailona_hosts **hostsp) ...@@ -299,7 +299,7 @@ vmod_hosts__fini(struct vmod_hoailona_hosts **hostsp)
if (a->pattern->re != NULL) if (a->pattern->re != NULL)
VRT_re_fini(a->pattern->re); VRT_re_fini(a->pattern->re);
} }
next_ass = VRB_NEXT(assign_tree, a, a); next_ass = VRBT_NEXT(assign_tree, a, a);
FREE_OBJ(a); FREE_OBJ(a);
a = next_ass; a = next_ass;
} }
...@@ -418,19 +418,19 @@ vmod_hosts_add(VRT_CTX, struct vmod_hoailona_hosts *hosts, ...@@ -418,19 +418,19 @@ vmod_hosts_add(VRT_CTX, struct vmod_hoailona_hosts *hosts,
hosts->vcl_name); hosts->vcl_name);
return; return;
} }
else if (path == NULL && !VRB_EMPTY(&host->assignments)) { else if (path == NULL && !VRBT_EMPTY(&host->assignments)) {
VERR(ctx, "Path-specific policies already set for " VERR(ctx, "Path-specific policies already set for "
"host %s in %s.add()", hostname, hosts->vcl_name); "host %s in %s.add()", hostname, hosts->vcl_name);
AZ(re); AZ(re);
return; return;
} }
else if (path != NULL && !VRB_EMPTY(&host->assignments)) { else if (path != NULL && !VRBT_EMPTY(&host->assignments)) {
struct pattern tmp_pattern; struct pattern tmp_pattern;
struct assignment tmp_assign, *result; struct assignment tmp_assign, *result;
tmp_pattern.path = (void *)path; tmp_pattern.path = (void *)path;
tmp_assign.pattern = &tmp_pattern; tmp_assign.pattern = &tmp_pattern;
if ((result = VRB_FIND(assign_tree, &host->assignments, if ((result = VRBT_FIND(assign_tree, &host->assignments,
&tmp_assign)) &tmp_assign))
!= NULL) { != NULL) {
VERR(ctx, "Policy %s already assigned for host " VERR(ctx, "Policy %s already assigned for host "
...@@ -448,7 +448,7 @@ vmod_hosts_add(VRT_CTX, struct vmod_hoailona_hosts *hosts, ...@@ -448,7 +448,7 @@ vmod_hosts_add(VRT_CTX, struct vmod_hoailona_hosts *hosts,
AN(host); AN(host);
host->name = strdup(hostname); host->name = strdup(hostname);
host->len = strlen(hostname); host->len = strlen(hostname);
VRB_INIT(&host->assignments); VRBT_INIT(&host->assignments);
AZ(host->description); AZ(host->description);
AZ(host->policy); AZ(host->policy);
VSTAILQ_INSERT_TAIL(&hosts->hosthead, host, list); VSTAILQ_INSERT_TAIL(&hosts->hosthead, host, list);
...@@ -473,7 +473,7 @@ vmod_hosts_add(VRT_CTX, struct vmod_hoailona_hosts *hosts, ...@@ -473,7 +473,7 @@ vmod_hosts_add(VRT_CTX, struct vmod_hoailona_hosts *hosts,
assign->pattern = pattern; assign->pattern = pattern;
if (description != NULL) if (description != NULL)
assign->description = strdup(description); assign->description = strdup(description);
AZ(VRB_INSERT(assign_tree, &host->assignments, assign)); AZ(VRBT_INSERT(assign_tree, &host->assignments, assign));
} }
VCL_INT VCL_INT
...@@ -567,8 +567,8 @@ vmod_hosts_policy(VRT_CTX, struct vmod_hoailona_hosts *hosts, ...@@ -567,8 +567,8 @@ vmod_hosts_policy(VRT_CTX, struct vmod_hoailona_hosts *hosts,
return -1; return -1;
/* There is a policy XOR there is a list of assignments */ /* There is a policy XOR there is a list of assignments */
assert((host->policy != NULL && VRB_EMPTY(&host->assignments)) assert((host->policy != NULL && VRBT_EMPTY(&host->assignments))
|| (host->policy == NULL && !VRB_EMPTY(&host->assignments))); || (host->policy == NULL && !VRBT_EMPTY(&host->assignments)));
if (host->policy != NULL) { if (host->policy != NULL) {
task->host = host; task->host = host;
task->policy = host->policy; task->policy = host->policy;
...@@ -579,9 +579,9 @@ vmod_hosts_policy(VRT_CTX, struct vmod_hoailona_hosts *hosts, ...@@ -579,9 +579,9 @@ vmod_hosts_policy(VRT_CTX, struct vmod_hoailona_hosts *hosts,
struct assignment *a, *assignment = NULL; struct assignment *a, *assignment = NULL;
int pathlen = strlen(pathname); int pathlen = strlen(pathname);
/* XXX lazily compute and save VRB_MIN for the host /* XXX lazily compute and save VRBT_MIN for the host
assignments, and re-use it to init the for loop */ assignments, and re-use it to init the for loop */
VRB_FOREACH(a, assign_tree, &host->assignments) { VRBT_FOREACH(a, assign_tree, &host->assignments) {
int match; int match;
CHECK_OBJ(a, VMOD_HOAILONA_ASSIGNMENT_MAGIC); CHECK_OBJ(a, VMOD_HOAILONA_ASSIGNMENT_MAGIC);
......
...@@ -58,18 +58,18 @@ struct vmod_hoailona_policy { ...@@ -58,18 +58,18 @@ struct vmod_hoailona_policy {
struct assignment { struct assignment {
unsigned magic; unsigned magic;
#define VMOD_HOAILONA_ASSIGNMENT_MAGIC 0x7523d6e8 #define VMOD_HOAILONA_ASSIGNMENT_MAGIC 0x7523d6e8
VRB_ENTRY(assignment) entry; VRBT_ENTRY(assignment) entry;
struct pattern *pattern; struct pattern *pattern;
struct vmod_hoailona_policy *policy; struct vmod_hoailona_policy *policy;
char *description; char *description;
}; };
VRB_HEAD(assign_tree, assignment); VRBT_HEAD(assign_tree, assignment);
int path_cmp(const struct assignment * restrict const ass_a, int path_cmp(const struct assignment * restrict const ass_a,
const struct assignment * restrict const ass_b); const struct assignment * restrict const ass_b);
VRB_PROTOTYPE(assign_tree, assignment, entry, path_cmp) VRBT_PROTOTYPE(assign_tree, assignment, entry, path_cmp)
void validation_init(void); void validation_init(void);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment