瀏覽代碼

modules_k/permissions: fixed handling of db connection

* Do not close db connection if query fails.
* Check that db connection exists before making a query
Juha Heinanen 16 年之前
父節點
當前提交
f26601329f
共有 1 個文件被更改,包括 3 次插入4 次删除
  1. 3 4
      modules_k/permissions/trusted.c

+ 3 - 4
modules_k/permissions/trusted.c

@@ -404,9 +404,9 @@ int allow_trusted(struct sip_msg* msg, char *src_ip, int proto)
 	db_val_t vals[1];
 	db_key_t cols[3];
 	
-	if (!db_url.s) {
-		LM_ERR("db_url parameter has not been set\n");
-		return -1;
+	if (db_handle == 0) {
+	    LM_ERR("no connection to database\n");
+	    return -1;
 	}
 
 	if (db_mode == DISABLE_CACHE) {
@@ -427,7 +427,6 @@ int allow_trusted(struct sip_msg* msg, char *src_ip, int proto)
 		if (perm_dbf.query(db_handle, keys, 0, vals, cols, 1, 3, 0,
 				   &res) < 0){
 			LM_ERR("failed to query database\n");
-			perm_dbf.close(db_handle);
 			return -1;
 		}