@@ -181,14 +181,16 @@ static int gw_status_update(bin_packet_t *packet, int raise_event)
181
181
lock_start_read (part -> ref_lock );
182
182
183
183
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
+ }
192
194
lock_stop_read (part -> ref_lock );
193
195
return 0 ;
194
196
}
@@ -218,12 +220,14 @@ static int cr_status_update(bin_packet_t *packet)
218
220
lock_start_read (part -> ref_lock );
219
221
220
222
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
+ }
227
231
lock_stop_read (part -> ref_lock );
228
232
return 0 ;
229
233
}
0 commit comments