Skip to content

Commit

Permalink
Fill REST api hostname for Ketama distribution
Browse files Browse the repository at this point in the history
Change-Id: Ia56c444340252e4bba6d4b6ca4e3299f9f2cb035
Reviewed-on: http://review.couchbase.org/12938
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
  • Loading branch information
avsej authored and trondn committed Feb 7, 2012
1 parent f9dfa4f commit ed1fbf0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/vbucket.c
Expand Up @@ -378,7 +378,7 @@ static int server_cmp(const void *s1, const void *s2)

static int parse_ketama_config(VBUCKET_CONFIG_HANDLE vb, cJSON *config)
{
cJSON *json, *node;
cJSON *json, *node, *hostname;
char *buf;
int ii;

Expand Down Expand Up @@ -409,6 +409,17 @@ static int parse_ketama_config(VBUCKET_CONFIG_HANDLE vb, cJSON *config)
return -1;
}
vb->servers[ii].authority = buf;
hostname = cJSON_GetObjectItem(node, "hostname");
if (hostname == NULL || hostname->type != cJSON_String) {
vb->errmsg = strdup("Expected string for node's hostname");
return -1;
}
buf = strdup(hostname->valuestring);
if (buf == NULL) {
vb->errmsg = strdup("Failed to allocate storage for hostname string");
return -1;
}
vb->servers[ii].rest_api_authority = buf;
}
qsort(vb->servers, vb->num_servers, sizeof(struct server_st), server_cmp);

Expand Down

0 comments on commit ed1fbf0

Please sign in to comment.