|
|
@ -1283,7 +1283,7 @@ static bool parse_serverurls(ckpool_t *ckp, const json_t *arr_val) |
|
|
|
if (!arr_val) |
|
|
|
if (!arr_val) |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
|
if (!json_is_array(arr_val)) { |
|
|
|
if (!json_is_array(arr_val)) { |
|
|
|
LOGWARNING("Unable to parse serverurl entries as an array"); |
|
|
|
LOGINFO("Unable to parse serverurl entries as an array"); |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} |
|
|
|
arr_size = json_array_size(arr_val); |
|
|
|
arr_size = json_array_size(arr_val); |
|
|
@ -1293,6 +1293,7 @@ static bool parse_serverurls(ckpool_t *ckp, const json_t *arr_val) |
|
|
|
} |
|
|
|
} |
|
|
|
ckp->serverurls = arr_size; |
|
|
|
ckp->serverurls = arr_size; |
|
|
|
ckp->serverurl = ckalloc(sizeof(char *) * arr_size); |
|
|
|
ckp->serverurl = ckalloc(sizeof(char *) * arr_size); |
|
|
|
|
|
|
|
ckp->nodeserver = ckzalloc(sizeof(bool) * arr_size); |
|
|
|
for (i = 0; i < arr_size; i++) { |
|
|
|
for (i = 0; i < arr_size; i++) { |
|
|
|
json_t *val = json_array_get(arr_val, i); |
|
|
|
json_t *val = json_array_get(arr_val, i); |
|
|
|
|
|
|
|
|
|
|
@ -1304,6 +1305,34 @@ out: |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void parse_nodeservers(ckpool_t *ckp, const json_t *arr_val) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int arr_size, i, j, total_urls; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!arr_val) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
if (!json_is_array(arr_val)) { |
|
|
|
|
|
|
|
LOGWARNING("Unable to parse nodeservers entries as an array"); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
arr_size = json_array_size(arr_val); |
|
|
|
|
|
|
|
if (!arr_size) { |
|
|
|
|
|
|
|
LOGWARNING("Nodeserver array empty"); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
total_urls = ckp->serverurls + arr_size; |
|
|
|
|
|
|
|
ckp->serverurl = realloc(ckp->serverurl, sizeof(char *) * total_urls); |
|
|
|
|
|
|
|
ckp->nodeserver = realloc(ckp->nodeserver, sizeof(bool) * total_urls); |
|
|
|
|
|
|
|
for (i = 0, j = ckp->serverurls; j < total_urls; i++, j++) { |
|
|
|
|
|
|
|
json_t *val = json_array_get(arr_val, i); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!_json_get_string(&ckp->serverurl[j], val, "nodeserver")) |
|
|
|
|
|
|
|
LOGWARNING("Invalid nodeserver entry number %d", i); |
|
|
|
|
|
|
|
ckp->nodeserver[j] = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ckp->serverurls = total_urls; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool parse_redirecturls(ckpool_t *ckp, const json_t *arr_val) |
|
|
|
static bool parse_redirecturls(ckpool_t *ckp, const json_t *arr_val) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool ret = false; |
|
|
|
bool ret = false; |
|
|
@ -1379,6 +1408,8 @@ static void parse_config(ckpool_t *ckp) |
|
|
|
ckp->serverurls = 1; |
|
|
|
ckp->serverurls = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
arr_val = json_object_get(json_conf, "nodeserver"); |
|
|
|
|
|
|
|
parse_nodeservers(ckp, arr_val); |
|
|
|
json_get_int64(&ckp->mindiff, json_conf, "mindiff"); |
|
|
|
json_get_int64(&ckp->mindiff, json_conf, "mindiff"); |
|
|
|
json_get_int64(&ckp->startdiff, json_conf, "startdiff"); |
|
|
|
json_get_int64(&ckp->startdiff, json_conf, "startdiff"); |
|
|
|
json_get_int64(&ckp->maxdiff, json_conf, "maxdiff"); |
|
|
|
json_get_int64(&ckp->maxdiff, json_conf, "maxdiff"); |
|
|
|