Project

General

Profile

OBSOLETE

This task is obsoleted by the new VLR feature.
osmo-nitb will be a GSUP client to osmo-hlr, and all access will hence be asynchronous.
See #1592

NITB asynchronous database access

Mentor Holger Freyther
Skills C
Length 10 days

Goal

The osmo-nitb application is using the libdbi for database access. libdbis offers the usage of a variety of different backends and currently only the sqlite3 backend is used. In order to be able to use the MySQL, Postgres or any other database there is some cleanup required. There is the need for some minor schema modifications to work on other databases but there is one more fundamental change. With SQLite3 the database is always local and the access is reasonable fast, when moving to MySQL/Postgres the database server might not be located on the same machine and access time might be slower. This is a problem because osmo-nitb is using the database synchronously.

Approach

Our database code is wrapped inside the 'db' module, the code can be found in src/libmsc/db.c and the code and the callers need to be changed to perform the database lookup in an asynchronous way. This means a function like db_get_subscriber may not return a struct gsm_subscriber immediately but it needs to call a callback once the subscriber has been loaded. This also requires the modification of all callers of this method. This means a function that used to do this:

#!C
struct gsm_subscriber *sub;

sub = db_get_subscriber(net, IMSI, imsi);
if (!subscr)
   return ERROR;
do_things_with_the_subsr(sub);

needs to be changed into two methods and maybe needs extra error handling

#!C
static void lu_subscr_cb(struct gsm_subscriber *subcr, void *data)
{
   struct gsm_subscriber_connection *conn = data;
   if (!subscr)
      return release_radio_channel(conn);
   do_things_with_the_subsr(sub);
}

...
db_get_subscriber(net, IMSI, imsi, lu_subscr_cb, conn);