[PATCH] openbsc[master]: lchan_alloc(): on alloc failure, report original type

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
Mon Jun 6 11:09:22 UTC 2016


Review at  https://gerrit.osmocom.org/205

lchan_alloc(): on alloc failure, report original type

In lchan_alloc(), there are several decisions to fall back to another type of
channel, followed by setting the channel type to the fall back type. So far,
this was set regardless of allocation success or failure.

If such fall back type is not available, do not modify the local type variable
and thus report an S_CHALLOC_ALLOC_FAIL on the type originally requested
(report is at the end of lchan_alloc()).

Change-Id: Ie3d4cb74f91db0b8c4f5e595a963099de339ad1a
---
M openbsc/src/libbsc/chan_alloc.c
1 file changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/05/205/1

diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c
index de9da81..c9c5fa8 100644
--- a/openbsc/src/libbsc/chan_alloc.c
+++ b/openbsc/src/libbsc/chan_alloc.c
@@ -161,12 +161,14 @@
 		if (allow_bigger) {
 			if (lchan == NULL) {
 				lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_H);
-				type = GSM_LCHAN_TCH_H;
+				if (lchan)
+					type = GSM_LCHAN_TCH_H;
 			}
 
 			if (lchan == NULL) {
 				lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_F);
-				type = GSM_LCHAN_TCH_F;
+				if (lchan)
+					type = GSM_LCHAN_TCH_F;
 			}
 		}
 		break;
@@ -175,7 +177,8 @@
 		/* If we don't have TCH/F available, fall-back to TCH/H */
 		if (!lchan) {
 			lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_H);
-			type = GSM_LCHAN_TCH_H;
+			if (lchan)
+				type = GSM_LCHAN_TCH_H;
 		}
 		break;
 	case GSM_LCHAN_TCH_H:
@@ -183,7 +186,8 @@
 		/* If we don't have TCH/H available, fall-back to TCH/F */
 		if (!lchan) {
 			lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_F);
-			type = GSM_LCHAN_TCH_F;
+			if (lchan)
+				type = GSM_LCHAN_TCH_F;
 		}
 		break;
 	default:

-- 
To view, visit https://gerrit.osmocom.org/205
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie3d4cb74f91db0b8c4f5e595a963099de339ad1a
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list