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/.
Keith Whyte gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/3910
libmsc: db_subscriber_alloc_exten() remove infinite loop
This is not right, but at least it prevents entering an
infinite loop in the case that you actually have exhasuted
all available extensions.
Change-Id: Icf0f1e5a7f360bc27592a55890f74a9a12bc9f42
---
M openbsc/src/libmsc/db.c
1 file changed, 9 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/10/3910/1
diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c
index 4ba12ca..d8f4876 100644
--- a/openbsc/src/libmsc/db.c
+++ b/openbsc/src/libmsc/db.c
@@ -1412,8 +1412,10 @@
{
dbi_result result = NULL;
uint64_t try;
+ int i;
+ int max_trys = smax - smin;
- for (;;) {
+ for (i = 0; i <= max_trys; i++) {
try = (rand() % (smax - smin + 1) + smin);
result = dbi_conn_queryf(conn,
"SELECT * FROM Subscriber "
@@ -1435,6 +1437,12 @@
}
dbi_result_free(result);
}
+
+ if (i > max_trys) {
+ DEBUGP(DDB, "Out of Trys, no extension for IMSI %s.\n", subscriber->imsi);
+ return -1;
+ }
+
sprintf(subscriber->extension, "%"PRIu64, try);
DEBUGP(DDB, "Allocated extension %"PRIu64 " for IMSI %s.\n", try, subscriber->imsi);
return db_sync_subscriber(subscriber);
--
To view, visit https://gerrit.osmocom.org/3910
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icf0f1e5a7f360bc27592a55890f74a9a12bc9f42
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Keith Whyte <keith at rhizomatica.org>