Update current NM object state before signalling S_NM_STATECHG

This way code triggered through signal has an updated view of the object
tree when running generic code which queries the current state of
objects.
This way for instance one can use APIs like trx_is_usable() or alike.

Change-Id: Ib46234e3f3e446e866d27b0dfee65edf4af4d2ba
This commit is contained in:
Pau Espin 2022-05-04 16:23:24 +02:00 committed by pespin
parent f8c8b0d9c5
commit b7ef6884f9
2 changed files with 8 additions and 5 deletions

View File

@ -230,8 +230,10 @@ static int update_admstate(struct gsm_bts *bts, uint8_t obj_class,
nsd.new_state.administrative = adm_state;
osmo_signal_dispatch(SS_NM, S_NM_STATECHG, &nsd);
/* Update current state before emitting signal: */
nm_state->administrative = adm_state;
osmo_signal_dispatch(SS_NM, S_NM_STATECHG, &nsd);
return 0;
}
@ -296,10 +298,10 @@ static int abis_nm_rx_statechg_rep(struct msgb *mb)
nsd.new_state.operational != nsd.old_state.operational ||
nsd.new_state.availability != nsd.old_state.availability) {
DEBUGPC(DNM, "\n");
/* Update the operational state of a given object in our in-memory data
/* Update the state of a given object in our in-memory data
* structures and send an event to the higher layer */
osmo_signal_dispatch(SS_NM, S_NM_STATECHG, &nsd);
*nm_state = nsd.new_state;
osmo_signal_dispatch(SS_NM, S_NM_STATECHG, &nsd);
} else {
DEBUGPC(DNM, "(No State change detected)\n");
}

View File

@ -992,9 +992,10 @@ static void update_mo_state(struct gsm_bts *bts, struct abis_om2k_mo *mo, uint8_
break;
}
osmo_signal_dispatch(SS_NM, S_NM_STATECHG, &nsd);
/* Update current state before emitting signal: */
nm_state->availability = nsd.new_state.availability;
osmo_signal_dispatch(SS_NM, S_NM_STATECHG, &nsd);
}
static void update_op_state(struct gsm_bts *bts, const struct abis_om2k_mo *mo, uint8_t op_state)