MT#55283 eliminate `config_lock`

Use relaxed-order atomic ops to access config variables that can be set
during run time.

Rename config_lock to keyspaces_lock as the keyspaces list remains the
only object that it protects.

All other config variables aren't settable at runtime and so don't
require locks or atomic ops.

Change-Id: I7e01a34a4818a558d5648ae27a86f9880a95d050
pull/1826/head
Richard Fuchs 2 years ago
parent 48b9206cee
commit 216f4f12fd

@ -150,10 +150,10 @@ static void call_timer_iterator(call_t *c, struct iterator_helper *hlp) {
rwlock_lock_r(&c->master_lock);
log_info_call(c);
rwlock_lock_r(&rtpe_config.config_lock);
// final timeout applicable to all calls (own and foreign)
if (rtpe_config.final_timeout && rtpe_now.tv_sec >= (c->created.tv_sec + rtpe_config.final_timeout)) {
if (atomic_get_na(&rtpe_config.final_timeout)
&& rtpe_now.tv_sec >= (c->created.tv_sec + atomic_get_na(&rtpe_config.final_timeout)))
{
ilog(LOG_INFO, "Closing call due to final timeout");
tmp_t_reason = FINAL_TIMEOUT;
for (__auto_type it = c->monologues.head; it; it = it->next) {
@ -184,7 +184,8 @@ static void call_timer_iterator(call_t *c, struct iterator_helper *hlp) {
goto out;
// ignore media timeout if call was recently taken over
if (CALL_ISSET(c, FOREIGN_MEDIA) && rtpe_now.tv_sec - c->last_signal <= rtpe_config.timeout)
if (CALL_ISSET(c, FOREIGN_MEDIA)
&& rtpe_now.tv_sec - c->last_signal <= atomic_get_na(&rtpe_config.timeout))
goto out;
for (__auto_type it = c->streams.head; it; it = it->next) {
@ -245,14 +246,14 @@ no_sfd:
if (good)
goto next;
check = rtpe_config.timeout;
check = atomic_get_na(&rtpe_config.timeout);
tmp_t_reason = TIMEOUT;
if (!MEDIA_ISSET(ps->media, RECV) || !sfd) {
check = rtpe_config.silent_timeout;
check = atomic_get_na(&rtpe_config.silent_timeout);
tmp_t_reason = SILENT_TIMEOUT;
}
else if (!PS_ISSET(ps, FILLED)) {
check = rtpe_config.offer_timeout;
check = atomic_get_na(&rtpe_config.offer_timeout);
tmp_t_reason = OFFER_TIMEOUT;
}
@ -304,7 +305,6 @@ delete:
goto out;
out:
rwlock_unlock_r(&rtpe_config.config_lock);
rwlock_unlock_r(&c->master_lock);
if (do_update)

@ -413,12 +413,10 @@ str *call_query_udp(char **out) {
rwlock_unlock_w(&c->master_lock);
rwlock_lock_r(&rtpe_config.config_lock);
ret = str_sprintf("%s %lld "UINT64F" "UINT64F" "UINT64F" "UINT64F"\n", out[RE_UDP_COOKIE],
(long long int) rtpe_config.silent_timeout - (rtpe_now.tv_sec - stats.last_packet),
(long long int) atomic_get_na(&rtpe_config.silent_timeout) - (rtpe_now.tv_sec - stats.last_packet),
atomic64_get_na(&stats.totals[0].packets), atomic64_get_na(&stats.totals[1].packets),
atomic64_get_na(&stats.totals[2].packets), atomic64_get_na(&stats.totals[3].packets));
rwlock_unlock_r(&rtpe_config.config_lock);
goto out;
err:
@ -2036,8 +2034,7 @@ void call_ng_free_flags(sdp_ng_flags *flags) {
static enum load_limit_reasons call_offer_session_limit(void) {
enum load_limit_reasons ret = LOAD_LIMIT_NONE;
rwlock_lock_r(&rtpe_config.config_lock);
if (rtpe_config.max_sessions>=0) {
if (atomic_get_na(&rtpe_config.max_sessions) >= 0) {
rwlock_lock_r(&rtpe_callhash_lock);
if (t_hash_table_size(rtpe_callhash) -
atomic64_get(&rtpe_stats_gauge.foreign_sessions) >= rtpe_config.max_sessions)
@ -2052,36 +2049,34 @@ static enum load_limit_reasons call_offer_session_limit(void) {
rwlock_unlock_r(&rtpe_callhash_lock);
}
if (ret == LOAD_LIMIT_NONE && rtpe_config.load_limit) {
if (ret == LOAD_LIMIT_NONE && atomic_get_na(&rtpe_config.load_limit)) {
int loadavg = g_atomic_int_get(&load_average);
if (loadavg >= rtpe_config.load_limit) {
if (loadavg >= atomic_get_na(&rtpe_config.load_limit)) {
ilog(LOG_WARN, "Load limit exceeded (%.2f > %.2f)",
(double) loadavg / 100.0, (double) rtpe_config.load_limit / 100.0);
ret = LOAD_LIMIT_LOAD;
}
}
if (ret == LOAD_LIMIT_NONE && rtpe_config.cpu_limit) {
if (ret == LOAD_LIMIT_NONE && atomic_get_na(&rtpe_config.cpu_limit)) {
int cpu = g_atomic_int_get(&cpu_usage);
if (cpu >= rtpe_config.cpu_limit) {
if (cpu >= atomic_get_na(&rtpe_config.cpu_limit)) {
ilog(LOG_WARN, "CPU usage limit exceeded (%.1f%% > %.1f%%)",
(double) cpu / 100.0, (double) rtpe_config.cpu_limit / 100.0);
ret = LOAD_LIMIT_CPU;
}
}
if (ret == LOAD_LIMIT_NONE && rtpe_config.bw_limit) {
if (ret == LOAD_LIMIT_NONE && atomic_get_na(&rtpe_config.bw_limit)) {
uint64_t bw = atomic64_get(&rtpe_stats_rate.bytes_user) +
atomic64_get(&rtpe_stats_rate.bytes_kernel);
if (bw >= rtpe_config.bw_limit) {
if (bw >= atomic_get_na(&rtpe_config.bw_limit)) {
ilog(LOG_WARN, "Bandwidth limit exceeded (%" PRIu64 " > %" PRIu64 ")",
bw, rtpe_config.bw_limit);
ret = LOAD_LIMIT_BW;
}
}
rwlock_unlock_r(&rtpe_config.config_lock);
return ret;
}

@ -393,11 +393,11 @@ static void cli_incoming_params_current(str *instr, struct cli_writer *cw) {
}
#define int_diff_print(struct_member, option_string) \
if (initial_rtpe_config.struct_member != rtpe_config.struct_member) { \
if (initial_rtpe_config.struct_member != atomic_get_na(&rtpe_config.struct_member)) { \
if (strcmp(option, "diff") == 0) \
cw->cw_printf(cw, "%s: %lld => %lld\n", option_string, \
(long long)initial_rtpe_config.struct_member, \
(long long)rtpe_config.struct_member); \
(long long)atomic_get_na(&rtpe_config.struct_member)); \
else if (strcmp(option, "revert") == 0) \
rtpe_config.struct_member = initial_rtpe_config.struct_member; \
}
@ -408,7 +408,6 @@ static void cli_incoming_diff_or_revert(struct cli_writer *cw, char* option) {
#include "loglevels.h"
#undef ll
rwlock_lock_w(&rtpe_config.config_lock);
int_diff_print(max_sessions, "max-sessions");
int_diff_print(cpu_limit, "max-cpu");
int_diff_print(load_limit, "max-load");
@ -421,7 +420,6 @@ static void cli_incoming_diff_or_revert(struct cli_writer *cw, char* option) {
int_diff_print(redis_disable_time, "redis_disable_time");
int_diff_print(redis_cmd_timeout, "redis_cmd_timeout");
int_diff_print(redis_connect_timeout, "redis_connect_timeout-db");
rwlock_unlock_w(&rtpe_config.config_lock);
}
static void cli_incoming_params_diff(str *instr, struct cli_writer *cw) {
@ -539,44 +537,16 @@ static void cli_incoming_list_maxopenfiles(str *instr, struct cli_writer *cw) {
}
static void cli_incoming_list_timeout(str *instr, struct cli_writer *cw) {
rwlock_lock_r(&rtpe_config.config_lock);
/* don't lock anything while reading the value */
cw->cw_printf(cw, "TIMEOUT=%u\n", rtpe_config.timeout);
rwlock_unlock_r(&rtpe_config.config_lock);
return ;
}
static void cli_incoming_list_silenttimeout(str *instr, struct cli_writer *cw) {
rwlock_lock_r(&rtpe_config.config_lock);
/* don't lock anything while reading the value */
cw->cw_printf(cw, "SILENT_TIMEOUT=%u\n", rtpe_config.silent_timeout);
rwlock_unlock_r(&rtpe_config.config_lock);
return ;
}
static void cli_incoming_list_finaltimeout(str *instr, struct cli_writer *cw) {
rwlock_lock_r(&rtpe_config.config_lock);
/* don't lock anything while reading the value */
cw->cw_printf(cw, "FINAL_TIMEOUT=%u\n", rtpe_config.final_timeout);
rwlock_unlock_r(&rtpe_config.config_lock);
return ;
}
static void cli_incoming_list_offertimeout(str *instr, struct cli_writer *cw) {
rwlock_lock_r(&rtpe_config.config_lock);
/* don't lock anything while reading the value */
cw->cw_printf(cw, "OFFER_TIMEOUT=%u\n", rtpe_config.offer_timeout);
rwlock_unlock_r(&rtpe_config.config_lock);
return ;
}
static void cli_incoming_list_callid(str *instr, struct cli_writer *cw) {
@ -851,14 +821,10 @@ static void cli_incoming_set_maxsessions(str *instr, struct cli_writer *cw) {
} else if (maxsessions_num < disabled) {
cw->cw_printf(cw, "Fail setting maxsessions to %ld; either positive or -1 values allowed\n", maxsessions_num);
} else if (maxsessions_num == disabled) {
rwlock_lock_w(&rtpe_config.config_lock);
rtpe_config.max_sessions = maxsessions_num;
rwlock_unlock_w(&rtpe_config.config_lock);
atomic_set_na(&rtpe_config.max_sessions, maxsessions_num);
cw->cw_printf(cw, "Success setting maxsessions to %ld; disable feature\n", maxsessions_num);
} else {
rwlock_lock_w(&rtpe_config.config_lock);
rtpe_config.max_sessions = maxsessions_num;
rwlock_unlock_w(&rtpe_config.config_lock);
atomic_set_na(&rtpe_config.max_sessions, maxsessions_num);
cw->cw_printf(cw, "Success setting maxsessions to %ld\n", maxsessions_num);
}
@ -884,9 +850,7 @@ static void cli_incoming_set_maxcpu(str *instr, struct cli_writer *cw) {
cw->cw_printf(cw, "Fail setting maxcpu to %s; no digists found\n", instr->s);
return;
} else {
rwlock_lock_w(&rtpe_config.config_lock);
rtpe_config.cpu_limit = num * 100;
rwlock_unlock_w(&rtpe_config.config_lock);
atomic_set_na(&rtpe_config.cpu_limit, num * 100);
cw->cw_printf(cw, "Success setting maxcpu to %.1f\n", num);
}
@ -911,9 +875,7 @@ static void cli_incoming_set_maxload(str *instr, struct cli_writer *cw) {
cw->cw_printf(cw, "Fail setting maxload to %s; no digists found\n", instr->s);
return;
} else {
rwlock_lock_w(&rtpe_config.config_lock);
rtpe_config.load_limit = num * 100;
rwlock_unlock_w(&rtpe_config.config_lock);
atomic_set_na(&rtpe_config.load_limit, num * 100);
cw->cw_printf(cw, "Success setting maxload to %.2f\n", num);
}
@ -938,9 +900,7 @@ static void cli_incoming_set_maxbw(str *instr, struct cli_writer *cw) {
cw->cw_printf(cw, "Fail setting maxbw to %s; no digists found\n", instr->s);
return;
} else {
rwlock_lock_w(&rtpe_config.config_lock);
rtpe_config.bw_limit = num;
rwlock_unlock_w(&rtpe_config.config_lock);
atomic_set_na(&rtpe_config.bw_limit, num);
cw->cw_printf(cw, "Success setting maxbw to %" PRIu64 "\n", num);
}
@ -966,9 +926,7 @@ static void cli_incoming_set_gentimeout(str *instr, struct cli_writer *cw, int *
cw->cw_printf(cw, "Fail setting timeout to %s; no digists found\n", instr->s);
return;
} else {
rwlock_lock_w(&rtpe_config.config_lock);
*conf_timeout = (int) timeout_num;
rwlock_unlock_w(&rtpe_config.config_lock);
atomic_set_na(conf_timeout, timeout_num);
cw->cw_printf(cw, "Success setting timeout to %lu\n", timeout_num);
}
}
@ -1100,7 +1058,7 @@ static void cli_incoming_ksadd(str *instr, struct cli_writer *cw) {
} else if (endptr == instr->s) {
cw->cw_printf(cw, "Fail adding keyspace %s to redis notifications; no digists found\n", instr->s);
} else {
rwlock_lock_w(&rtpe_config.config_lock);
rwlock_lock_w(&rtpe_config.keyspaces_lock);
if (!g_queue_find(&rtpe_config.redis_subscribed_keyspaces, GUINT_TO_POINTER(uint_keyspace_db))) {
g_queue_push_tail(&rtpe_config.redis_subscribed_keyspaces, GUINT_TO_POINTER(uint_keyspace_db));
redis_notify_subscribe_action(rtpe_redis_notify, SUBSCRIBE_KEYSPACE, uint_keyspace_db);
@ -1108,7 +1066,7 @@ static void cli_incoming_ksadd(str *instr, struct cli_writer *cw) {
} else {
cw->cw_printf(cw, "Keyspace %lu is already among redis notifications.\n", uint_keyspace_db);
}
rwlock_unlock_w(&rtpe_config.config_lock);
rwlock_unlock_w(&rtpe_config.keyspaces_lock);
}
}
@ -1125,7 +1083,7 @@ static void cli_incoming_ksrm(str *instr, struct cli_writer *cw) {
errno = 0;
uint_keyspace_db = strtoul(instr->s, &endptr, 10);
rwlock_lock_w(&rtpe_config.config_lock);
rwlock_lock_w(&rtpe_config.keyspaces_lock);
if ((errno == ERANGE && (uint_keyspace_db == ULONG_MAX)) || (errno != 0 && uint_keyspace_db == 0)) {
cw->cw_printf(cw, "Fail removing keyspace %s to redis notifications; errono=%d\n", instr->s, errno);
} else if (endptr == instr->s) {
@ -1144,7 +1102,7 @@ static void cli_incoming_ksrm(str *instr, struct cli_writer *cw) {
} else {
cw->cw_printf(cw, "Keyspace %lu is not among redis notifications.\n", uint_keyspace_db);
}
rwlock_unlock_w(&rtpe_config.config_lock);
rwlock_unlock_w(&rtpe_config.keyspaces_lock);
}
@ -1153,11 +1111,11 @@ static void cli_incoming_kslist(str *instr, struct cli_writer *cw) {
cw->cw_printf(cw, "\nSubscribed-on keyspaces:\n");
rwlock_lock_r(&rtpe_config.config_lock);
rwlock_lock_r(&rtpe_config.keyspaces_lock);
for (l = rtpe_config.redis_subscribed_keyspaces.head; l; l = l->next) {
cw->cw_printf(cw, "%u ", GPOINTER_TO_UINT(l->data));
}
rwlock_unlock_r(&rtpe_config.config_lock);
rwlock_unlock_r(&rtpe_config.keyspaces_lock);
cw->cw_printf(cw, "\n");
}
@ -1350,9 +1308,7 @@ static void cli_incoming_set_loglevel(str *instr, struct cli_writer *cw) {
}
static void cli_incoming_list_redisallowederrors(str *instr, struct cli_writer *cw) {
rwlock_lock_r(&rtpe_config.config_lock);
cw->cw_printf(cw, "%d\n", rtpe_config.redis_allowed_errors);
rwlock_unlock_r(&rtpe_config.config_lock);
cw->cw_printf(cw, "%d\n", atomic_get_na(&rtpe_config.redis_allowed_errors));
}
static void cli_incoming_set_redisallowederrors(str *instr, struct cli_writer *cw) {
@ -1367,17 +1323,13 @@ static void cli_incoming_set_redisallowederrors(str *instr, struct cli_writer *c
errno = 0;
allowed_errors = strtol(instr->s, &endptr, 10);
rwlock_lock_w(&rtpe_config.config_lock);
rtpe_config.redis_allowed_errors = allowed_errors;
rwlock_unlock_w(&rtpe_config.config_lock);
atomic_set_na(&rtpe_config.redis_allowed_errors, allowed_errors);
cw->cw_printf(cw, "Success setting redis-allowed-errors to %ld\n", allowed_errors);
}
static void cli_incoming_list_redisdisabletime(str *instr, struct cli_writer *cw) {
rwlock_lock_r(&rtpe_config.config_lock);
cw->cw_printf(cw, "%d\n", rtpe_config.redis_disable_time);
rwlock_unlock_r(&rtpe_config.config_lock);
cw->cw_printf(cw, "%d\n", atomic_get_na(&rtpe_config.redis_disable_time));
}
static void cli_incoming_set_redisdisable(str *instr, struct cli_writer *cw) {
@ -1436,17 +1388,13 @@ static void cli_incoming_set_redisdisabletime(str *instr, struct cli_writer *cw)
return;
}
rwlock_lock_w(&rtpe_config.config_lock);
rtpe_config.redis_disable_time = seconds;
rwlock_unlock_w(&rtpe_config.config_lock);
atomic_set_na(&rtpe_config.redis_disable_time, seconds);
cw->cw_printf(cw, "Success setting redis-disable-time to %ld\n", seconds);
}
static void cli_incoming_list_redisconnecttimeout(str *instr, struct cli_writer *cw) {
rwlock_lock_r(&rtpe_config.config_lock);
cw->cw_printf(cw, "%d\n", rtpe_config.redis_connect_timeout);
rwlock_unlock_r(&rtpe_config.config_lock);
cw->cw_printf(cw, "%d\n", atomic_get_na(&rtpe_config.redis_connect_timeout));
}
static void cli_incoming_set_redisconnecttimeout(str *instr, struct cli_writer *cw) {
@ -1464,16 +1412,12 @@ static void cli_incoming_set_redisconnecttimeout(str *instr, struct cli_writer *
cw->cw_printf(cw, "Invalid redis-connect-timeout value %ld, must be > 0\n", timeout);
return;
}
rwlock_lock_w(&rtpe_config.config_lock);
rtpe_config.redis_connect_timeout = timeout;
rwlock_unlock_w(&rtpe_config.config_lock);
atomic_set_na(&rtpe_config.redis_connect_timeout, timeout);
cw->cw_printf(cw, "Success setting redis-connect-timeout to %ld\n", timeout);
}
static void cli_incoming_list_deletedelay(str *instr, struct cli_writer *cw) {
rwlock_lock_r(&rtpe_config.config_lock);
cw->cw_printf(cw, "%d\n", rtpe_config.delete_delay);
rwlock_unlock_r(&rtpe_config.config_lock);
cw->cw_printf(cw, "%d\n", atomic_get_na(&rtpe_config.delete_delay));
}
static void cli_incoming_set_deletedelay(str *instr, struct cli_writer *cw) {
@ -1487,9 +1431,7 @@ static void cli_incoming_set_deletedelay(str *instr, struct cli_writer *cw) {
cw->cw_printf(cw, "Invalid delete-delay value\n");
return;
}
rwlock_lock_w(&rtpe_config.config_lock);
rtpe_config.delete_delay = seconds;
rwlock_unlock_w(&rtpe_config.config_lock);
atomic_set_na(&rtpe_config.delete_delay, seconds);
cw->cw_printf(cw, "Success setting delete-delay to %d\n", seconds);
}
@ -1632,9 +1574,7 @@ static void cli_incoming_tag_detdtmf(str *instr, struct cli_writer *cw) {
static void cli_incoming_list_rediscmdtimeout(str *instr, struct cli_writer *cw) {
rwlock_lock_r(&rtpe_config.config_lock);
cw->cw_printf(cw, "%d\n", rtpe_config.redis_cmd_timeout);
rwlock_unlock_r(&rtpe_config.config_lock);
cw->cw_printf(cw, "%d\n", atomic_get_na(&rtpe_config.redis_cmd_timeout));
}
static void cli_incoming_set_rediscmdtimeout(str *instr, struct cli_writer *cw) {
@ -1655,15 +1595,11 @@ static void cli_incoming_set_rediscmdtimeout(str *instr, struct cli_writer *cw)
return;
}
rwlock_lock_w(&rtpe_config.config_lock);
if (rtpe_config.redis_cmd_timeout == timeout) {
rwlock_unlock_w(&rtpe_config.config_lock);
if (atomic_get_na(&rtpe_config.redis_cmd_timeout) == timeout) {
cw->cw_printf(cw, "Success setting redis-cmd-timeout to %ld\n", timeout);
return;
}
rtpe_config.redis_cmd_timeout = timeout;
rwlock_unlock_w(&rtpe_config.config_lock);
atomic_set_na(&rtpe_config.redis_cmd_timeout, timeout);
if (timeout == 0) {
cw->cw_printf(cw, "Warning: Setting redis-cmd-timeout to 0 (no timeout) will require a redis reconnect\n");
@ -1791,9 +1727,7 @@ static void cli_incoming_list_transcoders(str *instr, struct cli_writer *cw) {
}
static void cli_incoming_list_controltos(str *instr, struct cli_writer *cw) {
rwlock_lock_r(&rtpe_config.config_lock);
cw->cw_printf(cw, "%d\n", rtpe_config.control_tos);
rwlock_unlock_r(&rtpe_config.config_lock);
cw->cw_printf(cw, "%d\n", atomic_get_na(&rtpe_config.control_tos));
}
static void cli_incoming_set_controltos(str *instr, struct cli_writer *cw) {
@ -1812,9 +1746,7 @@ static void cli_incoming_set_controltos(str *instr, struct cli_writer *cw) {
return;
}
rwlock_lock_w(&rtpe_config.config_lock);
rtpe_config.control_tos = tos;
rwlock_unlock_w(&rtpe_config.config_lock);
atomic_set_na(&rtpe_config.control_tos, tos);
for (GList *l = rtpe_control_ng.head; l; l = l->next) {
struct control_ng *c = l->data;

@ -507,8 +507,6 @@ static void options(int *argc, char ***argv) {
g_autoptr(char) nftables_family = NULL;
#endif
rwlock_lock_w(&rtpe_config.config_lock);
GOptionEntry e[] = {
{ "table", 't', 0, G_OPTION_ARG_INT, &rtpe_config.kernel_table, "Kernel table to use", "INT" },
{ "no-fallback",'F', 0, G_OPTION_ARG_NONE, &rtpe_config.no_fallback, "Only start when kernel module is available", NULL },
@ -1062,8 +1060,6 @@ static void options(int *argc, char ***argv) {
if (rtpe_config.cpu_affinity <= 0)
die("Number of CPU cores is unknown, cannot auto-set socket CPU affinity");
}
rwlock_unlock_w(&rtpe_config.config_lock);
}
static void fill_initial_rtpe_cfg(struct rtpengine_config* ini_rtpe_cfg) {
@ -1071,8 +1067,6 @@ static void fill_initial_rtpe_cfg(struct rtpengine_config* ini_rtpe_cfg) {
GList* l;
struct intf_config* gptr_data;
rwlock_lock_w(&rtpe_config.config_lock);
for(l = rtpe_config.interfaces.head; l ; l=l->next) {
gptr_data = g_slice_alloc0(sizeof(*gptr_data));
memcpy(gptr_data, (struct intf_config*)(l->data), sizeof(*gptr_data));
@ -1148,8 +1142,6 @@ static void fill_initial_rtpe_cfg(struct rtpengine_config* ini_rtpe_cfg) {
ini_rtpe_cfg->rtcp_interval = rtpe_config.rtcp_interval;
ini_rtpe_cfg->max_recv_iters = rtpe_config.max_recv_iters;
rwlock_unlock_w(&rtpe_config.config_lock);
}
static void
@ -1348,7 +1340,7 @@ static void create_everything(void) {
if (call_init())
abort();
rwlock_init(&rtpe_config.config_lock);
rwlock_init(&rtpe_config.keyspaces_lock);
create_listeners(&rtpe_config.tcp_listen_ep, &rtpe_tcp, (void *(*)(const endpoint_t *)) control_tcp_new, false, "TCP control");
create_listeners(&rtpe_config.udp_listen_ep, &rtpe_udp, (void *(*)(const endpoint_t *)) control_udp_new, true, "UDP control");

@ -265,10 +265,8 @@ static int redis_connect(struct redis *r, int wait) {
r->ctx = NULL;
r->current_db = -1;
rwlock_lock_r(&rtpe_config.config_lock);
connect_timeout = rtpe_config.redis_connect_timeout;
cmd_timeout = rtpe_config.redis_cmd_timeout;
rwlock_unlock_r(&rtpe_config.config_lock);
connect_timeout = atomic_get_na(&rtpe_config.redis_connect_timeout);
cmd_timeout = atomic_get_na(&rtpe_config.redis_cmd_timeout);
tv.tv_sec = (int) connect_timeout / 1000;
tv.tv_usec = (int) (connect_timeout % 1000) * 1000;
@ -755,11 +753,11 @@ static int redis_notify(struct redis *r) {
}
// subscribe to the values in the configured keyspaces
rwlock_lock_r(&rtpe_config.config_lock);
rwlock_lock_r(&rtpe_config.keyspaces_lock);
for (l = rtpe_config.redis_subscribed_keyspaces.head; l; l = l->next) {
redis_notify_subscribe_action(r, SUBSCRIBE_KEYSPACE, GPOINTER_TO_INT(l->data));
}
rwlock_unlock_r(&rtpe_config.config_lock);
rwlock_unlock_r(&rtpe_config.keyspaces_lock);
// dispatch event base => thread blocks here
if (event_base_dispatch(r->async_ev) < 0) {
@ -919,10 +917,8 @@ static void redis_count_err_and_disable(struct redis *r)
int allowed_errors;
int disable_time;
rwlock_lock_r(&rtpe_config.config_lock);
allowed_errors = rtpe_config.redis_allowed_errors;
disable_time = rtpe_config.redis_disable_time;
rwlock_unlock_r(&rtpe_config.config_lock);
allowed_errors = atomic_get_na(&rtpe_config.redis_allowed_errors);
disable_time = atomic_get_na(&rtpe_config.redis_disable_time);
if (allowed_errors < 0) {
return;

@ -32,8 +32,7 @@ enum endpoint_learning {
#endif
struct rtpengine_config {
/* everything below protected by config_lock */
rwlock_t config_lock;
rwlock_t keyspaces_lock;
struct rtpengine_common_config common;

Loading…
Cancel
Save