Skip to content

Commit 36b916a

Browse files
committed
[drouting] do not report error if replicated flags are the same
Avoid reporting error if the GW/Carrier replicated package does not change the existing status flags.
1 parent 736d35f commit 36b916a

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

modules/drouting/dr_clustering.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,16 @@ static int gw_status_update(bin_packet_t *packet, int raise_event)
181181
lock_start_read(part->ref_lock);
182182

183183
gw = get_gw_by_id(part->rdata->pgw_tree, &gw_id);
184-
if (gw && ((gw->flags&DR_DST_STAT_MASK)!=flags)) {
185-
/* import the status flags */
186-
gw->flags = ((~DR_DST_STAT_MASK)&gw->flags) | (DR_DST_STAT_MASK&flags);
187-
/* set the DIRTY flag to force flushing to DB */
188-
gw->flags |= DR_DST_STAT_DIRT_FLAG;
189-
if (raise_event)
190-
/* raise event for the status change */
191-
dr_raise_event(part, gw, MI_SSTR("replicated info"));
184+
if (gw) {
185+
if ((gw->flags&DR_DST_STAT_MASK)!=flags) {
186+
/* import the status flags */
187+
gw->flags = ((~DR_DST_STAT_MASK)&gw->flags) | (DR_DST_STAT_MASK&flags);
188+
/* set the DIRTY flag to force flushing to DB */
189+
gw->flags |= DR_DST_STAT_DIRT_FLAG;
190+
if (raise_event)
191+
/* raise event for the status change */
192+
dr_raise_event(part, gw, MI_SSTR("replicated info"));
193+
}
192194
lock_stop_read(part->ref_lock);
193195
return 0;
194196
}
@@ -218,12 +220,14 @@ static int cr_status_update(bin_packet_t *packet)
218220
lock_start_read(part->ref_lock);
219221

220222
cr = get_carrier_by_id(part->rdata->carriers_tree, &cr_id);
221-
if (cr && ((cr->flags&DR_CR_FLAG_IS_OFF)!=flags)) {
222-
/* import the status flags */
223-
cr->flags = ((~DR_CR_FLAG_IS_OFF)&cr->flags)|(DR_CR_FLAG_IS_OFF&flags);
224-
/* set the DIRTY flag to force flushing to DB */
225-
cr->flags |= DR_CR_FLAG_DIRTY;
226-
dr_raise_cr_event( part, cr, MI_SSTR("replicated info"));
223+
if (cr) {
224+
if ((cr->flags&DR_CR_FLAG_IS_OFF)!=flags) {
225+
/* import the status flags */
226+
cr->flags = ((~DR_CR_FLAG_IS_OFF)&cr->flags)|(DR_CR_FLAG_IS_OFF&flags);
227+
/* set the DIRTY flag to force flushing to DB */
228+
cr->flags |= DR_CR_FLAG_DIRTY;
229+
dr_raise_cr_event( part, cr, MI_SSTR("replicated info"));
230+
}
227231
lock_stop_read(part->ref_lock);
228232
return 0;
229233
}

0 commit comments

Comments
 (0)