[sr-dev] git:master: db_postgres: init DB API lib in mod_register()

Daniel-Constantin Mierla miconda at gmail.com
Tue Nov 1 20:33:57 CET 2011


Module: sip-router
Branch: master
Commit: b3b34accb2f65ccef6045b083879166cb1a1e060
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b3b34accb2f65ccef6045b083879166cb1a1e060

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Tue Nov  1 20:21:19 2011 +0100

db_postgres: init DB API lib in mod_register()

- this will initialize the sql buffer at module load time, avoiding
  crash at startup if a module using the DB driver is loaded before the
  db driver itself
- reported by Timo Teras

---

 modules/db_postgres/km_db_postgres.c |    2 +-
 modules/db_postgres/pg_mod.c         |    7 +++++++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/modules/db_postgres/km_db_postgres.c b/modules/db_postgres/km_db_postgres.c
index 73da2ae..9b0bd8b 100644
--- a/modules/db_postgres/km_db_postgres.c
+++ b/modules/db_postgres/km_db_postgres.c
@@ -73,7 +73,7 @@ struct kam_module_exports kam_exports = {
 
 int km_postgres_mod_init(void)
 {
-	return db_query_init();
+	return 0;
 }
 
 int db_postgres_bind_api(db_func_t *dbb)
diff --git a/modules/db_postgres/pg_mod.c b/modules/db_postgres/pg_mod.c
index 3c1e2d9..db78993 100644
--- a/modules/db_postgres/pg_mod.c
+++ b/modules/db_postgres/pg_mod.c
@@ -530,6 +530,13 @@ int pg_test(void)
 }
 #endif /* PG_TEST */
 
+int mod_register(char *path, int *dlflags, void *p1, void *p2)
+{
+	if(db_query_init()<0)
+		return -1;
+	return 0;
+}
+
 static int pg_mod_init(void)
 {
 #ifdef PG_TEST




More information about the sr-dev mailing list