openbsc[master]: libmsc: db_subscriber_alloc_exten() remove infinite loop

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/.

Pablo Neira Ayuso gerrit-no-reply at lists.osmocom.org
Tue Sep 12 11:54:58 UTC 2017


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/3910/1/openbsc/src/libmsc/db.c
File openbsc/src/libmsc/db.c:

Line 1419: 		try = (rand() % (smax - smin + 1) + smin);
Why don't we better update this code to use something better than a random function? To keep it simple, something like rand() to land on a space, then keep incrementally searching for an unused extension.

If the concern is only the infinite loop and the random function is fine, then just keep a global counter on the number of available extensions, so we can early give up on it.

My only concern with the random function is being _unlucky_, I mean, you get extensions that already used several times. But I'm not in touch with a real testbed, so I cannot tell how realistic this is.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Icf0f1e5a7f360bc27592a55890f74a9a12bc9f42
Gerrit-PatchSet: 1
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>
Gerrit-HasComments: Yes



More information about the gerrit-log mailing list