MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / frd_load_data

Function frd_load_data

modules/fraud_detection/frd_load.c:284–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282}
283
284static int frd_load_data(dr_head_p drp, free_list_t **fl)
285{
286 static const size_t col_count = 16;
287 db_res_t *res = NULL;
288 unsigned int no_rows = 0, row_count, i;
289 db_row_t *rows;
290 db_val_t *values;
291
292 db_key_t query_cols[] = {
293 &rid_col, &pid_col, &prefix_col, &start_h_col, &end_h_col, &days_col,
294 &cpm_thresh_warn_col, &cpm_thresh_crit_col, &calldur_thresh_warn_col,
295 &calldur_thresh_crit_col, &totalc_thresh_warn_col, &totalc_thresh_crit_col,
296 &concalls_thresh_warn_col, &concalls_thresh_crit_col, &seqcalls_thresh_warn_col,
297 &seqcalls_thresh_crit_col
298 };
299
300 if (db_handle == NULL) {
301 LM_ERR("Invalid db handler\n");
302 return -1;
303 }
304
305 if (dbf.use_table(db_handle, &table_name) != 0) {
306 LM_ERR("Cannot use table\n");
307 return -1;
308 }
309
310 if (DB_CAPABILITY(dbf, DB_CAP_FETCH)) {
311 if (dbf.query(db_handle, 0, 0, 0, query_cols, 0, col_count, 0, 0) != 0) {
312 LM_ERR("Error while querying db\n");
313 goto error;
314 }
315 /* estimate rows */
316 no_rows = estimate_available_rows(4 + 64 + 5 + 5 + 64 + 5 * 2 * 4, col_count);
317
318 if (no_rows == 0)
319 no_rows = 10;
320
321 if (dbf.fetch_result(db_handle, &res, no_rows) != 0) {
322 LM_ERR("Error while fetching rows\n");
323 goto error;
324 }
325 } else {
326 /* No fetching capability */
327 if (dbf.query(db_handle, 0, 0, 0, query_cols, 0, col_count, 0, &res) != 0) {
328 LM_ERR("Error while querying db\n");
329 goto error;
330 }
331 }
332
333 /* Process the actual data */
334
335 unsigned int rid, pid, j;
336 str prefix, start_time, end_time, days;
337 free_list_t *fl_it = NULL;
338 *fl = NULL;
339
340 do {
341 row_count = RES_ROW_N(res);

Callers 1

frd_reload_dataFunction · 0.85

Calls 3

estimate_available_rowsFunction · 0.85
shm_mallocFunction · 0.85
create_time_recFunction · 0.85

Tested by

no test coverage detected