Skip to content

Commit

Permalink
rtpengine: add ping_enabled switch
Browse files Browse the repository at this point in the history
add a switch to ping nodes even if they are enabled
  • Loading branch information
razvancrainea committed Aug 12, 2024
1 parent b2a7589 commit d18deac
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
25 changes: 25 additions & 0 deletions modules/rtpengine/doc/rtpengine_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,31 @@ modparam("rtpengine", "set_column", "set_new")
</example>
</section>

<section id="param_rtpengine_ping_enabled" xreflabel="ping_enabled">
<title><varname>ping_enabled</varname> (integer)</title>
<para>
This parameter indicates whether probing should be done for
enabled nodes as well.
</para>
<para>
If this parameter is set, each enabled node is pinged
every <xref linkend="param_rtpengine_timer_interval"/> seconds, unless
there was any communication with the node since the previous interval.
</para>
<para>
<emphasis>
Default value is <quote>0</quote> (disabled).
</emphasis>
</para>
<example>
<title>Set <varname>ping_enabled</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("rtpengine", "ping_enables", yes)
...
</programlisting>
</example>
</section>
</section>

<section>
Expand Down
8 changes: 7 additions & 1 deletion modules/rtpengine/rtpengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ static int rtpengine_stats_used = 0;
static int rtpengine_disable_tout = 60;
static int rtpengine_retr = 5;
static int rtpengine_tout = 1;
static int rtpengine_ping_enabled = 0;
static int rtpengine_timer_interval = 5;
static pid_t mypid;
static int myrand = 0;
Expand Down Expand Up @@ -696,6 +697,7 @@ static const param_export_t params[] = {
{"set_column", STR_PARAM, &db_rtpe_set_col.s },
{"notification_sock", STR_PARAM|USE_FUNC_PARAM,
(void *)rtpengine_set_notify},
{"ping_enabled", INT_PARAM, &rtpengine_ping_enabled },
{0, 0, 0}
};

Expand Down Expand Up @@ -1465,7 +1467,9 @@ void rtpengine_timer(unsigned int ticks, void *param)
rtpe_list = rtpe_list->rset_next){
for(crt_rtpe = rtpe_list->rn_first; crt_rtpe != NULL;
crt_rtpe = crt_rtpe->rn_next){
if (crt_rtpe->rn_disabled && crt_rtpe->rn_recheck_ticks <= get_ticks()) {
if ((crt_rtpe->rn_disabled && crt_rtpe->rn_recheck_ticks <= get_ticks()) ||
(rtpengine_ping_enabled && !crt_rtpe->rn_disabled &&
crt_rtpe->rn_last_ticks + rtpengine_timer_interval <= get_ticks())) {
disabled = crt_rtpe->rn_disabled;
crt_rtpe->rn_disabled = rtpe_test(crt_rtpe, 0, 1);
if (crt_rtpe->rn_disabled != disabled)
Expand Down Expand Up @@ -2929,6 +2933,7 @@ send_rtpe_command(struct rtpe_node *node, bencode_item_t *dict, int *outlen)
LM_ERR("can't read reply from a RTP proxy\n");
goto badproxy;
}
node->rn_last_ticks = get_ticks();
} else {
if (rtpe_socks[node->idx] != -1) {
fds[0].fd = rtpe_socks[node->idx];
Expand Down Expand Up @@ -2977,6 +2982,7 @@ send_rtpe_command(struct rtpe_node *node, bencode_item_t *dict, int *outlen)
RTPE_IO_ERROR_CLOSE(rtpe_socks[node->idx]);
continue;
}
node->rn_last_ticks = get_ticks();
if (len >= (v[0].iov_len - 1) &&
memcmp(buf, v[0].iov_base, (v[0].iov_len - 1)) == 0) {
len -= (v[0].iov_len - 1);
Expand Down
1 change: 1 addition & 0 deletions modules/rtpengine/rtpengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct rtpe_node {
int rn_disabled; /* found unaccessible? */
unsigned rn_weight; /* for load balancing */
unsigned int rn_recheck_ticks;
unsigned int rn_last_ticks;
int rn_flags;
struct rtpe_node *rn_next;
};
Expand Down

0 comments on commit d18deac

Please sign in to comment.