浏览代码

- fix: db connections should not be opened from child_init(PROC_MAIN),
or they will be inherited by all the tcp processes (bad). Bug reported by
Jan Andres <[email protected]>.

closes SER-227

Andrei Pelinescu-Onciul 18 年之前
父节点
当前提交
62925779f2
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      modules/db_postgres/dbase.c

+ 6 - 0
modules/db_postgres/dbase.c

@@ -39,6 +39,7 @@
 #include "../../dprint.h"
 #include "../../dprint.h"
 #include "../../db/db_pool.h"
 #include "../../db/db_pool.h"
 #include "../../ut.h"
 #include "../../ut.h"
+#include "../../globals.h"
 #include "pg_con.h"
 #include "pg_con.h"
 #include "pg_type.h"
 #include "pg_type.h"
 #include "db_mod.h"
 #include "db_mod.h"
@@ -227,6 +228,11 @@ db_con_t* pg_init(const char* url)
 	id = 0;
 	id = 0;
 	res = 0;
 	res = 0;
 
 
+	if (is_main){
+		LOG(L_ERR, "BUG: postgres: pg_init: called from the main process,"
+					" ignoring...\n");
+		return 0;
+	}
 	if (!url) {
 	if (!url) {
 		ERR("Invalid parameter value\n");
 		ERR("Invalid parameter value\n");
 		return 0;
 		return 0;