浏览代码

rtpengine: convert module to use DB_TABLE_VERSION_ERROR helper

        - convert module to use DB_TABLE_VERSION_ERROR helper
        - unify error handling (properly close database on errors, null db handle)
        - use abstract db_table_version_error function
Henning Westerholt 6 年之前
父节点
当前提交
d210ba8319
共有 1 个文件被更改,包括 2 次插入13 次删除
  1. 2 13
      src/modules/rtpengine/rtpengine_db.c

+ 2 - 13
src/modules/rtpengine/rtpengine_db.c

@@ -139,7 +139,6 @@ static int rtpp_load_db(void)
 int init_rtpproxy_db(void)
 {
 	int ret;
-	int rtpp_table_version;
 	if (rtpp_db_url.s == NULL)
 		/* Database not configured */
 		return 0;
@@ -155,22 +154,12 @@ int init_rtpproxy_db(void)
 		return -1;
 	}
 
-	rtpp_table_version = db_table_version(&rtpp_dbf, rtpp_db_handle, &rtpp_table_name);
-	if (rtpp_table_version < 0)
+	if (db_check_table_version(&rtpp_dbf, rtpp_db_handle, &rtpp_table_name, RTPP_TABLE_VERSION) < 0)
 	{
-		LM_ERR("failed to get rtpp table version\n");
+		DB_TABLE_VERSION_ERROR(rtpp_table_name);
 		ret = -1;
 		goto done;
 	}
-	switch (rtpp_table_version) {
-		case RTPP_TABLE_VERSION:
-			break;
-		default:
-			LM_ERR("invalid table version (found %d, require %d)\n",
-			  rtpp_table_version, RTPP_TABLE_VERSION);
-			ret = -1;
-			goto done;
-	}
 	ret = rtpp_load_db();
 
 done: