Change in osmo-bsc[master]: lchan_fsm: lchan_fail_to(): store target state early

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Aug 29 01:11:53 UTC 2018


Neels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/10636 )

Change subject: lchan_fsm: lchan_fail_to(): store target state early
......................................................................

lchan_fsm: lchan_fail_to(): store target state early

lchan_fail_to() is a macro to preserve useful source file:line information in
logging. But a side effect is that its target state argument might evaluate
differently at the end of the macro, if, say, the fi->state has changed.

I hit such an instance on timeout of WAIT_RLL_RTP_ESTABLISH:
lchan_fsm_timer_cb() calls macro lchan_fail(), which calls
lchan_fail_to(lchan_fsm_on_error[fi->state]). Unlike for normal function
invocation, this argument changes as fi->state changes. Since releasing the
lchan_rtp_fsm already transitions the lchan fi into WAIT_RF_RELEASE_ACK, the
final state change of lchan_fail_to() suddenly evaluates to the broken state
instead of the intended WAIT_RF_RELEASE_ACK.

Early in lchan_fail_to(), store the argument's value as of macro invocation.

Change-Id: Id9bf4580a112ee5629f553a8bcb6b5b03b1c5f53
---
M src/osmo-bsc/lchan_fsm.c
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c
index 9c22bde..e0015cb 100644
--- a/src/osmo-bsc/lchan_fsm.c
+++ b/src/osmo-bsc/lchan_fsm.c
@@ -211,9 +211,11 @@
 
 /* Set a failure message, trigger the common actions to take on failure, transition to a state to
  * continue with (using state timeouts from lchan_fsm_timeouts[]). Assumes local variable fi exists. */
-#define lchan_fail_to(state_chg, fmt, args...) do { \
+#define lchan_fail_to(STATE_CHG, fmt, args...) do { \
 		struct gsm_lchan *_lchan = fi->priv; \
 		uint32_t state_was = fi->state; \
+		/* Snapshot the target state, in case the macro argument evaluates differently later */ \
+		const uint32_t state_chg = STATE_CHG; \
 		lchan_set_last_error(_lchan, "lchan %s in state %s: " fmt, \
 				     _lchan->activate.concluded ? "failure" : "allocation failed", \
 				     osmo_fsm_state_name(fi->fsm, state_was), ## args); \

-- 
To view, visit https://gerrit.osmocom.org/10636
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id9bf4580a112ee5629f553a8bcb6b5b03b1c5f53
Gerrit-Change-Number: 10636
Gerrit-PatchSet: 3
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180829/fc71c3f6/attachment.htm>


More information about the gerrit-log mailing list