Skip to content

Commit

Permalink
rtpengine: add set in the E_RTPENGINE_STATUS event
Browse files Browse the repository at this point in the history
When having the same node in multiple sets, this event will be triggered
multiple times, but there is no way of figuring out for which set it has
been triggered. Adding the set allows you to do a better management of
the event, and also filter it better.

Many thanks to Wayne Davies from Five9 for reporting this issue!
  • Loading branch information
razvancrainea committed Oct 23, 2024
1 parent 9287274 commit 4e5a6e1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/rtpengine/doc/rtpengine_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ modparam("rtpengine", "set_column", "set_new")
<title>Set <varname>ping_enabled</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("rtpengine", "ping_enables", yes)
modparam("rtpengine", "ping_enabled", yes)
...
</programlisting>
</example>
Expand Down Expand Up @@ -1673,6 +1673,10 @@ $ opensips-cli -x mi teardown Y2IwYjQ2YmE2ZDg5MWVkNDNkZGIwZjAzNGM1ZDY0ZDQ
the RTPEngine instance responds to probing or
<emphasis>inactive</emphasis> if the instance was deactivated.
</para></listitem>
<listitem><para>
<emphasis>set</emphasis> - the numeric id of the set
this RTPEngine instance is part of.
</para></listitem>
</itemizedlist>
</section>
</section>
Expand Down
12 changes: 12 additions & 0 deletions modules/rtpengine/rtpengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,10 @@ static event_id_t rtpengine_status_event = EVI_ERROR;
static evi_params_p rtpengine_status_event_params;
static str rtpengine_status_event_socket_s = str_init("socket");
static str rtpengine_status_event_status_s = str_init("status");
static str rtpengine_status_event_set_s = str_init("set");
static evi_param_p rtpengine_status_event_socket;
static evi_param_p rtpengine_status_event_status;
static evi_param_p rtpengine_status_event_set;
static inline void raise_rtpengine_status_event(struct rtpe_node *node);

/* array with the sockets used by rtpengine (per process)*/
Expand Down Expand Up @@ -1016,6 +1018,7 @@ static int add_rtpengine_socks(struct rtpe_set * rtpe_list,
return -1;
}
memset(pnode, 0, sizeof(*pnode));
pnode->set = rtpe_list->id_set;
pnode->rn_recheck_ticks = 0;
pnode->rn_weight = weight;
pnode->rn_umode = 0;
Expand Down Expand Up @@ -1594,6 +1597,11 @@ mod_init(void)
LM_ERR("could not create RTPEngine Status status param\n");
return -1;
}
if ((rtpengine_status_event_set = evi_param_create(rtpengine_status_event_params,
&rtpengine_status_event_set_s)) == NULL) {
LM_ERR("could not create RTPEngine Status set param\n");
return -1;
}

if(db_url.s == NULL) {
/* storing the list of rtp proxy sets in shared memory*/
Expand Down Expand Up @@ -4766,6 +4774,10 @@ static inline void raise_rtpengine_status_event(struct rtpe_node *node)
LM_ERR("cannot set rtpengine status parameter\n");
return;
}
if (evi_param_set_int(rtpengine_status_event_set, &node->set) < 0) {
LM_ERR("cannot set rtpengine status parameter\n");
return;
}
if (evi_raise_event(rtpengine_status_event, rtpengine_status_event_params))
LM_ERR("unable to send event\n");
}
1 change: 1 addition & 0 deletions modules/rtpengine/rtpengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

struct rtpe_node {
unsigned int idx; /* overall index */
unsigned int set; /* id of the set index */
str rn_url; /* unparsed, deletable, NULL-term */
int rn_umode;
char *rn_address; /* substring of rn_url */
Expand Down

0 comments on commit 4e5a6e1

Please sign in to comment.