Browse code

ims_charging: 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)

Henning Westerholt authored on 30/12/2018 23:45:52
Showing 1 changed files
... ...
@@ -98,8 +98,8 @@ int init_ro_db(const str *db_url, int dlg_hash_size, int db_update_period, int f
98 98
     }
99 99
 
100 100
     if (db_check_table_version(&ro_dbf, ro_db_handle, &ro_session_table_name, RO_TABLE_VERSION) < 0) {
101
-	LM_ERR("error during dialog-table version check.\n");
102
-	return -1;
101
+	DB_TABLE_VERSION_ERROR(ro_session_table_name);
102
+	goto dberror;
103 103
     }
104 104
 
105 105
     //	if( (dlg_db_mode==DB_MODE_DELAYED) && 
... ...
@@ -110,13 +110,18 @@ int init_ro_db(const str *db_url, int dlg_hash_size, int db_update_period, int f
110 110
 
111 111
     if ((load_ro_info_from_db(dlg_hash_size, fetch_num_rows)) != 0) {
112 112
 	LM_ERR("unable to load the dialog data\n");
113
-	return -1;
113
+	goto dberror;
114 114
     }
115 115
 
116 116
     ro_dbf.close(ro_db_handle);
117 117
     ro_db_handle = 0;
118 118
 
119 119
     return 0;
120
+
121
+dberror:
122
+    ro_dbf.close(ro_db_handle);
123
+    ro_db_handle = 0;
124
+    return -1;
120 125
 }
121 126
 
122 127
 int load_ro_info_from_db(int hash_size, int fetch_num_rows) {