浏览代码

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
Daniel-Constantin Mierla 14 年之前
父节点
当前提交
b3b34accb2
共有 2 个文件被更改,包括 8 次插入1 次删除
  1. 1 1
      modules/db_postgres/km_db_postgres.c
  2. 7 0
      modules/db_postgres/pg_mod.c

+ 1 - 1
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)

+ 7 - 0
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