[PATCH 2/3] use thread-safe DBI interface instead of deprecated one

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/OpenBSC@lists.osmocom.org/.

Max max.suraev at fairwaves.co
Wed Jul 29 18:20:29 UTC 2015


Signed-off-by: Max <max.suraev at fairwaves.co>
---
 debian/control          | 2 +-
 openbsc/configure.ac    | 1 +
 openbsc/src/libmsc/db.c | 7 ++++---
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/debian/control b/debian/control
index ad0cc89..af305f9 100644
--- a/debian/control
+++ b/debian/control
@@ -2,7 +2,7 @@ Source: openbsc
 Section: net
 Priority: optional
 Maintainer: Harald Welte <laforge at gnumonks.org>
-Build-Depends: debhelper (>= 7.0.0~), autotools-dev, pkg-config, libgtp0-dev, libosmocore-dev, libosmo-sccp-dev, libdbi0-dev, dh-autoreconf, libosmo-abis-dev, libosmo-netif-dev, libdbd-sqlite3, libpcap-dev
+Build-Depends: debhelper (>= 7.0.0~), autotools-dev, pkg-config, libgtp0-dev, libosmocore-dev, libosmo-sccp-dev, libdbi-dev (>= 0.9.0), dh-autoreconf, libosmo-abis-dev, libosmo-netif-dev, libdbd-sqlite3, libpcap-dev
 Standards-Version: 3.8.4
 Homepage: http://openbsc.osmocom.org/
 Vcs-Git: git://bs11-abis.gnumonks.org/openbsc.git
diff --git a/openbsc/configure.ac b/openbsc/configure.ac
index 0ebb041..c07467e 100644
--- a/openbsc/configure.ac
+++ b/openbsc/configure.ac
@@ -27,6 +27,7 @@ PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.7.0)
 PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.2.0)
 PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 0.6.4)
 PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.0.1)
+PKG_CHECK_MODULES(LIBDBI, dbi >= 0.9.0)
 
 # Enabke/disable the NAT?
 AC_ARG_ENABLE([nat], [AS_HELP_STRING([--enable-nat], [Build the BSC NAT. Requires SCCP])],
diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c
index 035202d..9b0ce43 100644
--- a/openbsc/src/libmsc/db.c
+++ b/openbsc/src/libmsc/db.c
@@ -44,6 +44,7 @@ void subscr_direct_free(struct gsm_subscriber *subscr);
 static char *db_basename = NULL;
 static char *db_dirname = NULL;
 static dbi_conn conn;
+static dbi_inst dbi_instance = 0;
 
 #define SCHEMA_REVISION "4"
 
@@ -425,9 +426,9 @@ static int db_configure(void)
 
 int db_init(const char *name)
 {
-	dbi_initialize(NULL);
+	dbi_initialize_r(NULL, &dbi_instance);
 
-	conn = dbi_conn_new("sqlite3");
+	conn = dbi_conn_new_r("sqlite3", dbi_instance);
 	if (conn == NULL) {
 		LOGP(DDB, LOGL_FATAL, "Failed to create connection.\n");
 		return 1;
@@ -491,7 +492,7 @@ int db_prepare(void)
 int db_fini(void)
 {
 	dbi_conn_close(conn);
-	dbi_shutdown();
+	dbi_shutdown_r(dbi_instance);
 
 	free(db_dirname);
 	free(db_basename);
-- 
2.1.4




More information about the OpenBSC mailing list