Skip to content

Commit

Permalink
only check for duplicate server name and not 'host:port:weight' when …
Browse files Browse the repository at this point in the history
…'name' is configured
  • Loading branch information
Manju Rajashekhar committed Mar 1, 2013
1 parent e5d3d94 commit 10b2f14
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions src/nc_conf.c
Expand Up @@ -1109,14 +1109,6 @@ conf_pre_validate(struct conf *cf)
return NC_OK;
}

static int
conf_server_pname_cmp(const void *t1, const void *t2)
{
const struct conf_server *s1 = t1, *s2 = t2;

return string_compare(&s1->pname, &s2->pname);
}

static int
conf_server_name_cmp(const void *t1, const void *t2)
{
Expand Down Expand Up @@ -1156,27 +1148,10 @@ conf_validate_server(struct conf *cf, struct conf_pool *cp)

/*
* Disallow duplicate servers - servers with identical "host:port:weight"
* or "name" combination are considered as duplicates
* or "name" combination are considered as duplicates. When server name
* is configured, we only check for duplicate "name" and not for duplicate
* "host:port:weight"
*/
array_sort(&cp->server, conf_server_pname_cmp);
for (valid = true, i = 0; i < nserver - 1; i++) {
struct conf_server *cs1, *cs2;

cs1 = array_get(&cp->server, i);
cs2 = array_get(&cp->server, i + 1);

if (string_compare(&cs1->pname, &cs2->pname) == 0) {
log_error("conf: pool '%.*s' has servers with same name '%.*s'",
cp->name.len, cp->name.data, cs1->pname.len,
cs1->pname.data);
valid = false;
break;
}
}
if (!valid) {
return NC_ERROR;
}

array_sort(&cp->server, conf_server_name_cmp);
for (valid = true, i = 0; i < nserver - 1; i++) {
struct conf_server *cs1, *cs2;
Expand Down

0 comments on commit 10b2f14

Please sign in to comment.