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

Function ds_load_data

modules/dispatcher/dispatch.c:1041–1214  ·  view source on GitHub ↗

load groups of destinations from DB*/

Source from the content-addressed store, hash-verified

1039
1040/*load groups of destinations from DB*/
1041static ds_data_t* ds_load_data(ds_partition_t *partition)
1042{
1043 ds_data_t *d_data;
1044 int i, id, nr_rows, cnt, nr_cols = 9;
1045 int state;
1046 int weight;
1047 int prio;
1048 int probe_mode;
1049 const struct socket_info *sock;
1050 str uri;
1051 str attrs, weight_st;
1052 str description;
1053 db_res_t * res = NULL;
1054 db_val_t * values;
1055 db_row_t * rows;
1056 int discarded_dst=0;
1057
1058 db_key_t query_cols[9] = {&ds_set_id_col, &ds_dest_uri_col,
1059 &ds_dest_sock_col, &ds_dest_weight_col, &ds_dest_attrs_col,
1060 &ds_dest_prio_col, &ds_dest_description_col,
1061 &ds_dest_probe_mode_col, &ds_dest_state_col};
1062
1063 if (!partition->persistent_state)
1064 nr_cols--;
1065
1066 if(*partition->db_handle == NULL){
1067 LM_ERR("invalid DB handler\n");
1068 return NULL;
1069 }
1070
1071 if (partition->dbf.use_table(*partition->db_handle, &partition->table_name)
1072 < 0) {
1073 LM_ERR("error in use_table\n");
1074 return NULL;
1075 }
1076
1077 d_data = (ds_data_t*)shm_malloc( sizeof(ds_data_t) );
1078 if (d_data==NULL) {
1079 LM_ERR("failed to allocate new data structure in shm\n");
1080 return NULL;
1081 }
1082 memset( d_data, 0, sizeof(ds_data_t));
1083
1084 sr_add_report( ds_srg, STR2CI(partition->name),
1085 CHAR_INT("starting DB data loading"), 0 /*is_public*/);
1086
1087 /*select the whole table and all the columns*/
1088 if(partition->dbf.query(*partition->db_handle,0,0,0,query_cols,0,nr_cols,
1089 0,&res) < 0) {
1090 LM_ERR("error while querying database\n");
1091 goto error;
1092 }
1093
1094 cnt = 0;
1095
1096 nr_rows = RES_ROW_N(res);
1097 rows = RES_ROWS(res);
1098 if(nr_rows == 0) {

Callers 1

ds_reload_dbFunction · 0.85

Calls 9

shm_mallocFunction · 0.85
sr_add_reportFunction · 0.85
parse_sock_infoFunction · 0.85
is_fs_urlFunction · 0.85
str2intFunction · 0.85
add_dest2listFunction · 0.85
reindex_destsFunction · 0.85
sr_add_report_fmtFunction · 0.85
ds_destroy_data_setFunction · 0.85

Tested by

no test coverage detected