[PATCH 3/3] lchan: Handle the abnormal case of channel getting closed

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/OpenBSC@lists.osmocom.org/.

Holger Freyther zecke at selfish.org
Fri Jun 5 02:18:49 UTC 2009


The abnormal case is that lchan_free ist getting called due
a RSL_MT_CHAN_REL_ACK in the RSL but the refcount of this
channel is not zero. This means that some "logical operation"
is still going on that needs to be cancelled.
Instead of always queuing up all operations in the
struct lchan use the signal framework to inform higher layers
about this abnormal case.

In gsm_04_08.c a signal handler is installed and in the
abnormal case the location updating request operation is
freed.
---
 include/openbsc/signal.h |   10 ++++++++++
 src/chan_alloc.c         |    4 +++-
 src/gsm_04_08.c          |   18 ++++++++++++++++++
 3 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/include/openbsc/signal.h b/include/openbsc/signal.h
index c2cf46a..ca16296 100644
--- a/include/openbsc/signal.h
+++ b/include/openbsc/signal.h
@@ -37,6 +37,7 @@ enum signal_subsystems {
 	SS_SMS,
 	SS_ABISIP,
 	SS_NM,
+	SS_LCHAN,
 };
 
 /* SS_PAGING signals */
@@ -55,6 +56,15 @@ enum signal_nm {
 	S_NM_FAIL_REP,		/* GSM 12.21 failure event report */
 };
 
+/* SS_LCHAN signals */
+enum signal_lchan {
+	/*
+	 * The lchan got freed with refcount != 0 and error
+	 * recovery needs to happen right now.
+	 */
+	S_LCHAN_UNEXPECTED_RELEASE,
+};
+
 typedef int signal_cbfn(unsigned int subsys, unsigned int signal,
 			void *handler_data, void *signal_data);
 
diff --git a/src/chan_alloc.c b/src/chan_alloc.c
index fa07273..77a4f57 100644
--- a/src/chan_alloc.c
+++ b/src/chan_alloc.c
@@ -31,6 +31,7 @@
 #include <openbsc/abis_nm.h>
 #include <openbsc/abis_rsl.h>
 #include <openbsc/debug.h>
+#include <openbsc/signal.h>
 
 static void auto_release_channel(void *_lchan);
 
@@ -193,8 +194,9 @@ void lchan_free(struct gsm_lchan *lchan)
 		lchan->subscr = 0;
 	}
 
-	/* We might kill an active channel... FIXME: call cancellations */
+	/* We might kill an active channel... */
 	if (lchan->use_count != 0) {
+		dispatch_signal(SS_LCHAN, S_LCHAN_UNEXPECTED_RELEASE, lchan);
 		lchan->use_count = 0;
 	}
 
diff --git a/src/gsm_04_08.c b/src/gsm_04_08.c
index 18371b5..3dfa780 100644
--- a/src/gsm_04_08.c
+++ b/src/gsm_04_08.c
@@ -182,6 +182,24 @@ static void allocate_loc_updating_req(struct gsm_lchan 
*lchan)
 	memset(lchan->loc_operation, 0, sizeof(*lchan->loc_operation));
 }
 
+static int gsm0408_handle_lchan_signal(unsigned int subsys, unsigned int 
signal,
+					void *handler_data, void *signal_data)
+{
+	if (subsys != SS_LCHAN || signal != S_LCHAN_UNEXPECTED_RELEASE)
+		return 0;
+
+	/* give up on the loc_operation in case of error */
+	struct gsm_lchan *lchan = (struct gsm_lchan *)handler_data;
+	release_loc_updating_req(lchan);
+
+	return 0;
+}
+
+static __attribute__((constructor)) void on_load_0408(void)
+{
+	register_signal_handler(SS_LCHAN, gsm0408_handle_lchan_signal, NULL);
+}
+
 static void to_bcd(u_int8_t *bcd, u_int16_t val)
 {
 	bcd[2] = val % 10;
-- 
1.6.3.1






More information about the OpenBSC mailing list