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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Sep 14 14:26:04 UTC 2017


Patch Set 5:

To avoid loops altogether, I'm thinking of an SQL approach:

One part of the solution is the random picking:

  SELECT * FROM table ORDER BY RANDOM() LIMIT 1;

The other part would be to select from a list of *unused* values.
This one looks promising:
https://www.xaprb.com/blog/2005/12/06/find-missing-numbers-in-a-sequence-with-sql/

"

  select l.id + 1 as start
  from sequence as l
    left outer join sequence as r on l.id + 1 = r.id
  where r.id is null;

The idea is to exclusion join against the same sequence, but shifted by one position. Any number with an adjacent number will join successfully, and the WHERE clause will eliminate successful matches, leaving the missing numbers.

"

That could work, right?

-- 
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: 5
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: No



More information about the gerrit-log mailing list