Add "hiredis" config block, with keep_alive_sec

Only one option available for now, as discussed.
master
Jessie Murray 1 year ago
parent c7b0e4a6b7
commit 4c335bbe8e
No known key found for this signature in database
GPG Key ID: E7E4D57EDDA744C5

@ -31,6 +31,9 @@ conf_auth_legacy(char *password);
static struct auth * static struct auth *
conf_auth_username_password(json_t *jarray); conf_auth_username_password(json_t *jarray);
static void
conf_parse_hiredis(struct conf *conf, json_t *jhiredis);
int int
conf_str_allcaps(const char *s, const size_t sz) { conf_str_allcaps(const char *s, const size_t sz) {
size_t i; size_t i;
@ -211,6 +214,8 @@ conf_read(const char *filename) {
} else if(strcmp(json_object_iter_key(kv), "ssl") == 0 && json_typeof(jtmp) == JSON_OBJECT) { } else if(strcmp(json_object_iter_key(kv), "ssl") == 0 && json_typeof(jtmp) == JSON_OBJECT) {
conf_parse_ssl(conf, jtmp, filename); conf_parse_ssl(conf, jtmp, filename);
#endif #endif
} else if(strcmp(json_object_iter_key(kv), "hiredis") == 0 && json_typeof(jtmp) == JSON_OBJECT) {
conf_parse_hiredis(conf, jtmp);
} else { } else {
fprintf(stderr, "Warning! Unexpected key or incorrect value in %s: '%s'\n", filename, json_object_iter_key(kv)); fprintf(stderr, "Warning! Unexpected key or incorrect value in %s: '%s'\n", filename, json_object_iter_key(kv));
} }
@ -420,3 +425,16 @@ conf_auth_username_password(json_t *jarray) {
ret->password = password; ret->password = password;
return ret; return ret;
} }
static void
conf_parse_hiredis(struct conf *conf, json_t *jhiredis) {
for(void *kv = json_object_iter(jhiredis); kv; kv = json_object_iter_next(jhiredis, kv)) {
json_t *jtmp = json_object_iter_value(kv);
const char *key = json_object_iter_key(kv);
if(strcmp(key, "keep_alive_sec") == 0 && json_typeof(jtmp) == JSON_INTEGER) {
conf->hiredis_opts.keep_alive_sec = (int)json_integer_value(jtmp);
} else {
fprintf(stderr, "Config error under 'hiredis': unknown key '%s'.", key);
}
}
}

@ -52,6 +52,11 @@ struct conf {
int period_millis; /* only used with LOG_FSYNC_MILLIS */ int period_millis; /* only used with LOG_FSYNC_MILLIS */
} log_fsync; } log_fsync;
/* HiRedis options */
struct {
int keep_alive_sec; /* passed to redisEnableKeepAliveWithInterval, > 0 to enable */
} hiredis_opts;
#ifdef HAVE_SSL #ifdef HAVE_SSL
/* SSL */ /* SSL */
struct { struct {

Loading…
Cancel
Save