Skip to content

Commit

Permalink
Fix loosing destination status during reload.
Browse files Browse the repository at this point in the history
Preserve the status (enabled or not) during a data reload from DB.

(cherry picked from commit c2df8a8)
  • Loading branch information
bogdan-iancu committed Feb 14, 2017
1 parent c1d5b33 commit e46490b
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion modules/load_balancer/load_balancer.c
Expand Up @@ -295,6 +295,32 @@ static int fixup_cnt_call(void** param, int param_no)
return -1;
}

static void lb_inherit_state(struct lb_data *old_data,struct lb_data *new_data)
{
struct lb_dst *old_dst;
struct lb_dst *new_dst;

for ( new_dst=new_data->dsts ; new_dst ; new_dst=new_dst->next ) {
for ( old_dst=old_data->dsts ; old_dst ; old_dst=old_dst->next ) {
if (new_dst->id==old_dst->id &&
new_dst->group==old_dst->group &&
new_dst->uri.len==old_dst->uri.len &&
strncasecmp(new_dst->uri.s, old_dst->uri.s, old_dst->uri.len)==0) {
LM_DBG("DST %d/<%.*s> found in old set, copying state\n",
new_dst->group, new_dst->uri.len,new_dst->uri.s);
/* first reset the existing flags (only the flags related
* to state!!!) */
new_dst->flags &=
~(LB_DST_STAT_DSBL_FLAG|LB_DST_STAT_NOEN_FLAG);
/* copy the flags from the old node */
new_dst->flags |= (old_dst->flags &
(LB_DST_STAT_DSBL_FLAG|LB_DST_STAT_NOEN_FLAG));
break;
}
}
}
}


static inline int lb_reload_data( void )
{
Expand All @@ -316,8 +342,12 @@ static inline int lb_reload_data( void )
lock_stop_write( ref_lock );

/* destroy old data */
if (old_data)
if (old_data) {
/* copy the state of the destinations from the old set
* (for the matching ids) */
lb_inherit_state( old_data, new_data);
free_lb_data( old_data );
}

/* generate new blacklist from the routing info */
populate_lb_bls((*curr_data)->dsts);
Expand Down

0 comments on commit e46490b

Please sign in to comment.