Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completely disabled state persists over opensips restart #3105

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion db/schema/load_balancer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<type>unsigned int</type>
<size>11</size>
<default>0</default>
<description>Probing mode (0-none, 1-if disabled, 2-all the time)</description>
<description>Probing mode (0-none, 1-if disabled, 2-all the time, 12-completly disabled)</description>
</column>

<column id="attrs">
Expand Down
13 changes: 12 additions & 1 deletion modules/load_balancer/doc/load_balancer_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -913,11 +913,23 @@ if (lb_is_destination($si,$sp) ) {
<para>
Trigers the reload of the load balancing data from the DB.
</para>

<itemizedlist>
<listitem><para><emphasis>inherit_state</emphasis> (optional) : whether inherit old state of the destination , default is y. </para>
<itemizedlist>
<listitem><para> <quote>n</quote>: no inherit state </para></listitem>
<listitem><para> <quote>y</quote>: inherit state </para></listitem>
</itemizedlist>
</listitem>

</itemizedlist>

<para>
MI FIFO Command Format:
</para>
<programlisting format="linespecific">
opensips-cli -x mi lb_reload
opensips-cli -x mi lb_reload inherit_state=n
</programlisting>
</section>

Expand Down Expand Up @@ -1028,4 +1040,3 @@ enable:: yes


</chapter>

3 changes: 3 additions & 0 deletions modules/load_balancer/lb_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ int lb_db_load_data( struct lb_data *data)
pmode = VAL_INT(ROW_VALUES(row)+4);
if (pmode==0) {
flags |= LB_DST_PING_DSBL_FLAG;
} else if (pmode==LB_DST_STAT_MASK) {
/* DST is disabled from the db if the PROBING is 12 */
flags |= LB_DST_STAT_MASK;
} else if (pmode>=2) {
flags |= LB_DST_PING_PERM_FLAG;
}
Expand Down
13 changes: 9 additions & 4 deletions modules/load_balancer/load_balancer.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ static const param_export_t mod_params[]={
static const mi_export_t mi_cmds[] = {
{ "lb_reload", 0, 0, mi_child_init, {
{mi_lb_reload, {0}},
{mi_lb_reload, {"inherit_state", 0}},
{EMPTY_MI_RECIPE}}
},
{ "lb_resize", 0, 0, 0, {
Expand Down Expand Up @@ -313,7 +314,7 @@ static void lb_inherit_state(struct lb_data *old_data,struct lb_data *new_data)
}


static inline int lb_reload_data( void )
static inline int lb_reload_data(const int is_inherit_state)
{
struct lb_data *new_data;
struct lb_data *old_data;
Expand All @@ -336,7 +337,9 @@ static inline int lb_reload_data( void )
if (old_data) {
/* copy the state of the destinations from the old set
* (for the matching ids) */
lb_inherit_state( old_data, new_data);
if (is_inherit_state)
lb_inherit_state( old_data, new_data);

free_lb_data( old_data );
}

Expand Down Expand Up @@ -393,7 +396,7 @@ static int mod_init(void)
}

/* load data */
if ( lb_reload_data()!=0 ) {
if ( lb_reload_data(1)!=0 ) {
LM_CRIT("failed to load load-balancing data\n");
return -1;
}
Expand Down Expand Up @@ -827,9 +830,11 @@ static void lb_update_max_loads(unsigned int ticks, void *param)
mi_response_t *mi_lb_reload(const mi_params_t *params,
struct mi_handler *async_hdl)
{
int is_inherit_state = get_mi_bool_like_param(params, "inherit_state", 1);

LM_INFO("\"lb_reload\" MI command received!\n");

if ( lb_reload_data()!=0 ) {
if ( lb_reload_data(is_inherit_state)!=0 ) {
LM_CRIT("failed to load load balancing data\n");
goto error;
}
Expand Down