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.orgHello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/3910 to look at the new patch set (#2). 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, 21 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/10/3910/2 diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 4ba12ca..74ee58b 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -1412,8 +1412,22 @@ { dbi_result result = NULL; uint64_t try; + int total_subs; + int i; + int max_trys; - for (;;) { + result = dbi_conn_query(conn, "SELECT count(*) AS total FROM Subscriber"); + if (!result) { + LOGP(DDB, LOGL_ERROR, "Failed to get subscriber count " + "while allocating new extension.\n"); + return 1; + } + + dbi_result_next_row(result); + total_subs = atoi( dbi_result_get_string(result, "total") ); + max_trys = smax - smin - total_subs; + + for (i = 0; i <= max_trys; i++) { try = (rand() % (smax - smin + 1) + smin); result = dbi_conn_queryf(conn, "SELECT * FROM Subscriber " @@ -1435,6 +1449,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: newpatchset Gerrit-Change-Id: Icf0f1e5a7f360bc27592a55890f74a9a12bc9f42 Gerrit-PatchSet: 2 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Keith Whyte <keith at rhizomatica.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Keith Whyte <keith at rhizomatica.org> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Pablo Neira Ayuso <pablo at gnumonks.org>