aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-06-06 12:57:22 +0200
committerHolger Freyther <holger@freyther.de>2016-06-07 11:10:40 +0000
commitf5713a5c6376db139250debd9c2ae36f8e974982 (patch)
tree6ea2733ba37c4feded75626deb32a81bc438d207
parent6079528b4858ec15dc029778d86fb43197ba77db (diff)
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
-rw-r--r--openbsc/src/libbsc/chan_alloc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c
index de9da810d..c9c5fa8c8 100644
--- a/openbsc/src/libbsc/chan_alloc.c
+++ b/openbsc/src/libbsc/chan_alloc.c
@@ -161,12 +161,14 @@ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type,
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 @@ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type,
/* 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 @@ struct gsm_lchan *lchan_alloc(struct gsm_bts *bts, enum gsm_chan_t type,
/* 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: