- use module specific prefix
... | ... |
@@ -113,13 +113,13 @@ extern int ds_load_mode; |
113 | 113 |
static db_func_t ds_dbf; |
114 | 114 |
static db1_con_t *ds_db_handle = NULL; |
115 | 115 |
|
116 |
-ds_set_t **ds_lists = NULL; |
|
116 |
+static ds_set_t **ds_lists = NULL; |
|
117 | 117 |
|
118 |
-int *ds_list_nr = NULL; |
|
119 |
-int *crt_idx = NULL; |
|
120 |
-int *next_idx = NULL; |
|
118 |
+static int *ds_list_nr = NULL; |
|
119 |
+static int *ds_crt_idx = NULL; |
|
120 |
+static int *ds_next_idx = NULL; |
|
121 | 121 |
|
122 |
-#define _ds_list (ds_lists[*crt_idx]) |
|
122 |
+#define _ds_list (ds_lists[*ds_crt_idx]) |
|
123 | 123 |
#define _ds_list_nr (*ds_list_nr) |
124 | 124 |
|
125 | 125 |
static void ds_run_route(struct sip_msg *msg, str *uri, char *route, |
... | ... |
@@ -267,10 +267,10 @@ int ds_init_data(void) |
267 | 267 |
} |
268 | 268 |
memset(p, 0, 3 * sizeof(int)); |
269 | 269 |
|
270 |
- crt_idx = p; |
|
271 |
- next_idx = p + 1; |
|
270 |
+ ds_crt_idx = p; |
|
271 |
+ ds_next_idx = p + 1; |
|
272 | 272 |
ds_list_nr = p + 2; |
273 |
- *crt_idx = *next_idx = 0; |
|
273 |
+ *ds_crt_idx = *ds_next_idx = 0; |
|
274 | 274 |
|
275 | 275 |
return 0; |
276 | 276 |
} |
... | ... |
@@ -784,7 +784,7 @@ int ds_load_list(char *lfile) |
784 | 784 |
str uri; |
785 | 785 |
str attrs; |
786 | 786 |
|
787 |
- if((*crt_idx) != (*next_idx)) { |
|
787 |
+ if((*ds_crt_idx) != (*ds_next_idx)) { |
|
788 | 788 |
LM_WARN("load command already generated, aborting reload...\n"); |
789 | 789 |
return 0; |
790 | 790 |
} |
... | ... |
@@ -802,8 +802,8 @@ int ds_load_list(char *lfile) |
802 | 802 |
|
803 | 803 |
id = setn = flags = priority = 0; |
804 | 804 |
|
805 |
- *next_idx = (*crt_idx + 1) % 2; |
|
806 |
- ds_avl_destroy(&ds_lists[*next_idx]); |
|
805 |
+ *ds_next_idx = (*ds_crt_idx + 1) % 2; |
|
806 |
+ ds_avl_destroy(&ds_lists[*ds_next_idx]); |
|
807 | 807 |
|
808 | 808 |
p = fgets(line, 1024, f); |
809 | 809 |
while(p) { |
... | ... |
@@ -878,7 +878,7 @@ int ds_load_list(char *lfile) |
878 | 878 |
attrs.len = p - attrs.s; |
879 | 879 |
|
880 | 880 |
add_destination: |
881 |
- if(add_dest2list(id, uri, flags, priority, &attrs, *next_idx, &setn, 0) |
|
881 |
+ if(add_dest2list(id, uri, flags, priority, &attrs, *ds_next_idx, &setn, 0) |
|
882 | 882 |
!= 0) { |
883 | 883 |
LM_WARN("unable to add destination %.*s to set %d -- skipping\n", |
884 | 884 |
uri.len, uri.s, id); |
... | ... |
@@ -890,7 +890,7 @@ next_line: |
890 | 890 |
p = fgets(line, 1024, f); |
891 | 891 |
} |
892 | 892 |
|
893 |
- if(reindex_dests(ds_lists[*next_idx]) != 0) { |
|
893 |
+ if(reindex_dests(ds_lists[*ds_next_idx]) != 0) { |
|
894 | 894 |
LM_ERR("error on reindex\n"); |
895 | 895 |
goto error; |
896 | 896 |
} |
... | ... |
@@ -899,7 +899,7 @@ next_line: |
899 | 899 |
f = NULL; |
900 | 900 |
/* Update list - should it be sync'ed? */ |
901 | 901 |
_ds_list_nr = setn; |
902 |
- *crt_idx = *next_idx; |
|
902 |
+ *ds_crt_idx = *ds_next_idx; |
|
903 | 903 |
|
904 | 904 |
LM_DBG("found [%d] dest sets\n", _ds_list_nr); |
905 | 905 |
|
... | ... |
@@ -909,8 +909,8 @@ next_line: |
909 | 909 |
error: |
910 | 910 |
if(f != NULL) |
911 | 911 |
fclose(f); |
912 |
- ds_avl_destroy(&ds_lists[*next_idx]); |
|
913 |
- *next_idx = *crt_idx; |
|
912 |
+ ds_avl_destroy(&ds_lists[*ds_next_idx]); |
|
913 |
+ *ds_next_idx = *ds_crt_idx; |
|
914 | 914 |
return -1; |
915 | 915 |
} |
916 | 916 |
|
... | ... |
@@ -1048,7 +1048,7 @@ int ds_load_db(void) |
1048 | 1048 |
} |
1049 | 1049 |
} |
1050 | 1050 |
|
1051 |
- if((*crt_idx) != (*next_idx)) { |
|
1051 |
+ if((*ds_crt_idx) != (*ds_next_idx)) { |
|
1052 | 1052 |
LM_WARN("load command already generated, aborting reload...\n"); |
1053 | 1053 |
return 0; |
1054 | 1054 |
} |
... | ... |
@@ -1079,8 +1079,8 @@ int ds_load_db(void) |
1079 | 1079 |
} |
1080 | 1080 |
|
1081 | 1081 |
setn = 0; |
1082 |
- *next_idx = (*crt_idx + 1) % 2; |
|
1083 |
- ds_avl_destroy(&ds_lists[*next_idx]); |
|
1082 |
+ *ds_next_idx = (*ds_crt_idx + 1) % 2; |
|
1083 |
+ ds_avl_destroy(&ds_lists[*ds_next_idx]); |
|
1084 | 1084 |
|
1085 | 1085 |
for(i = 0; i < nr_rows; i++) { |
1086 | 1086 |
values = ROW_VALUES(rows + i); |
... | ... |
@@ -1128,7 +1128,7 @@ int ds_load_db(void) |
1128 | 1128 |
} |
1129 | 1129 |
} |
1130 | 1130 |
LM_DBG("attributes string: [%.*s]\n", attrs.len, (attrs.s)?attrs.s:""); |
1131 |
- if(add_dest2list(id, uri, flags, priority, &attrs, *next_idx, &setn, 0) |
|
1131 |
+ if(add_dest2list(id, uri, flags, priority, &attrs, *ds_next_idx, &setn, 0) |
|
1132 | 1132 |
!= 0) { |
1133 | 1133 |
dest_errs++; |
1134 | 1134 |
LM_WARN("unable to add destination %.*s to set %d -- skipping\n", |
... | ... |
@@ -1138,7 +1138,7 @@ int ds_load_db(void) |
1138 | 1138 |
} |
1139 | 1139 |
} |
1140 | 1140 |
} |
1141 |
- if(reindex_dests(ds_lists[*next_idx]) != 0) { |
|
1141 |
+ if(reindex_dests(ds_lists[*ds_next_idx]) != 0) { |
|
1142 | 1142 |
LM_ERR("error on reindex\n"); |
1143 | 1143 |
goto err2; |
1144 | 1144 |
} |
... | ... |
@@ -1147,7 +1147,7 @@ int ds_load_db(void) |
1147 | 1147 |
|
1148 | 1148 |
/* update data - should it be sync'ed? */ |
1149 | 1149 |
_ds_list_nr = setn; |
1150 |
- *crt_idx = *next_idx; |
|
1150 |
+ *ds_crt_idx = *ds_next_idx; |
|
1151 | 1151 |
|
1152 | 1152 |
LM_DBG("found [%d] dest sets\n", _ds_list_nr); |
1153 | 1153 |
|
... | ... |
@@ -1158,9 +1158,9 @@ int ds_load_db(void) |
1158 | 1158 |
return 0; |
1159 | 1159 |
|
1160 | 1160 |
err2: |
1161 |
- ds_avl_destroy(&ds_lists[*next_idx]); |
|
1161 |
+ ds_avl_destroy(&ds_lists[*ds_next_idx]); |
|
1162 | 1162 |
ds_dbf.free_result(ds_db_handle, res); |
1163 |
- *next_idx = *crt_idx; |
|
1163 |
+ *ds_next_idx = *ds_crt_idx; |
|
1164 | 1164 |
|
1165 | 1165 |
return -1; |
1166 | 1166 |
} |
... | ... |
@@ -1174,8 +1174,8 @@ int ds_destroy_list(void) |
1174 | 1174 |
shm_free(ds_lists); |
1175 | 1175 |
} |
1176 | 1176 |
|
1177 |
- if(crt_idx) |
|
1178 |
- shm_free(crt_idx); |
|
1177 |
+ if(ds_crt_idx) |
|
1178 |
+ shm_free(ds_crt_idx); |
|
1179 | 1179 |
|
1180 | 1180 |
return 0; |
1181 | 1181 |
} |
... | ... |
@@ -1615,7 +1615,7 @@ int ds_load_replace(struct sip_msg *msg, str *duid) |
1615 | 1615 |
} |
1616 | 1616 |
set = it->dset; |
1617 | 1617 |
/* get the index of the set */ |
1618 |
- if(ds_get_index(set, *crt_idx, &idx) != 0) { |
|
1618 |
+ if(ds_get_index(set, *ds_crt_idx, &idx) != 0) { |
|
1619 | 1619 |
ds_unlock_cell(_dsht_load, &msg->callid->body); |
1620 | 1620 |
LM_ERR("destination set [%d] not found\n", set); |
1621 | 1621 |
return -1; |
... | ... |
@@ -1676,7 +1676,7 @@ int ds_load_remove_byid(int set, str *duid) |
1676 | 1676 |
int i; |
1677 | 1677 |
|
1678 | 1678 |
/* get the index of the set */ |
1679 |
- if(ds_get_index(set, *crt_idx, &idx) != 0) { |
|
1679 |
+ if(ds_get_index(set, *ds_crt_idx, &idx) != 0) { |
|
1680 | 1680 |
LM_ERR("destination set [%d] not found\n", set); |
1681 | 1681 |
return -1; |
1682 | 1682 |
} |
... | ... |
@@ -2276,7 +2276,7 @@ int ds_manage_routes(sip_msg_t *msg, ds_select_state_t *rstate) |
2276 | 2276 |
|
2277 | 2277 |
|
2278 | 2278 |
/* get the index of the set */ |
2279 |
- if(ds_get_index(rstate->setid, *crt_idx, &idx) != 0) { |
|
2279 |
+ if(ds_get_index(rstate->setid, *ds_crt_idx, &idx) != 0) { |
|
2280 | 2280 |
LM_ERR("destination set [%d] not found\n", rstate->setid); |
2281 | 2281 |
return -1; |
2282 | 2282 |
} |
... | ... |
@@ -2579,7 +2579,7 @@ void ds_add_dest_cb(ds_set_t *node, int i, void *arg) |
2579 | 2579 |
int setn; |
2580 | 2580 |
|
2581 | 2581 |
if(add_dest2list(node->id, node->dlist[i].uri, node->dlist[i].flags, |
2582 |
- node->dlist[i].priority, &node->dlist[i].attrs.body, *next_idx, |
|
2582 |
+ node->dlist[i].priority, &node->dlist[i].attrs.body, *ds_next_idx, |
|
2583 | 2583 |
&setn, node->dlist[i].dload) != 0) { |
2584 | 2584 |
LM_WARN("failed to add destination in group %d - %.*s\n", |
2585 | 2585 |
node->id, node->dlist[i].uri.len, node->dlist[i].uri.s); |
... | ... |
@@ -2595,35 +2595,35 @@ int ds_add_dst(int group, str *address, int flags, str *attrs) |
2595 | 2595 |
setn = _ds_list_nr; |
2596 | 2596 |
priority = 0; |
2597 | 2597 |
|
2598 |
- *next_idx = (*crt_idx + 1) % 2; |
|
2599 |
- ds_avl_destroy(&ds_lists[*next_idx]); |
|
2598 |
+ *ds_next_idx = (*ds_crt_idx + 1) % 2; |
|
2599 |
+ ds_avl_destroy(&ds_lists[*ds_next_idx]); |
|
2600 | 2600 |
|
2601 | 2601 |
// add all existing destinations |
2602 | 2602 |
ds_iter_set(_ds_list, &ds_add_dest_cb, NULL); |
2603 | 2603 |
|
2604 | 2604 |
// add new destination |
2605 | 2605 |
if(add_dest2list(group, *address, flags, priority, attrs, |
2606 |
- *next_idx, &setn, 0) != 0) { |
|
2606 |
+ *ds_next_idx, &setn, 0) != 0) { |
|
2607 | 2607 |
LM_WARN("unable to add destination %.*s to set %d", address->len, address->s, group); |
2608 | 2608 |
if(ds_load_mode==1) { |
2609 | 2609 |
goto error; |
2610 | 2610 |
} |
2611 | 2611 |
} |
2612 | 2612 |
|
2613 |
- if(reindex_dests(ds_lists[*next_idx]) != 0) { |
|
2613 |
+ if(reindex_dests(ds_lists[*ds_next_idx]) != 0) { |
|
2614 | 2614 |
LM_ERR("error on reindex\n"); |
2615 | 2615 |
goto error; |
2616 | 2616 |
} |
2617 | 2617 |
|
2618 | 2618 |
_ds_list_nr = setn; |
2619 |
- *crt_idx = *next_idx; |
|
2619 |
+ *ds_crt_idx = *ds_next_idx; |
|
2620 | 2620 |
|
2621 | 2621 |
ds_log_sets(); |
2622 | 2622 |
return 0; |
2623 | 2623 |
|
2624 | 2624 |
error: |
2625 |
- ds_avl_destroy(&ds_lists[*next_idx]); |
|
2626 |
- *next_idx = *crt_idx; |
|
2625 |
+ ds_avl_destroy(&ds_lists[*ds_next_idx]); |
|
2626 |
+ *ds_next_idx = *ds_crt_idx; |
|
2627 | 2627 |
return -1; |
2628 | 2628 |
} |
2629 | 2629 |
|
... | ... |
@@ -2637,7 +2637,7 @@ void ds_filter_dest_cb(ds_set_t *node, int i, void *arg) |
2637 | 2637 |
return; |
2638 | 2638 |
|
2639 | 2639 |
if(add_dest2list(node->id, node->dlist[i].uri, node->dlist[i].flags, |
2640 |
- node->dlist[i].priority, &node->dlist[i].attrs.body, *next_idx, |
|
2640 |
+ node->dlist[i].priority, &node->dlist[i].attrs.body, *ds_next_idx, |
|
2641 | 2641 |
filter_arg->setn, node->dlist[i].dload) != 0) { |
2642 | 2642 |
LM_WARN("failed to add destination in group %d - %.*s\n", |
2643 | 2643 |
node->id, node->dlist[i].uri.len, node->dlist[i].uri.s); |
... | ... |
@@ -2659,26 +2659,26 @@ int ds_remove_dst(int group, str *address) |
2659 | 2659 |
filter_arg.dest = dp; |
2660 | 2660 |
filter_arg.setn = &setn; |
2661 | 2661 |
|
2662 |
- *next_idx = (*crt_idx + 1) % 2; |
|
2663 |
- ds_avl_destroy(&ds_lists[*next_idx]); |
|
2662 |
+ *ds_next_idx = (*ds_crt_idx + 1) % 2; |
|
2663 |
+ ds_avl_destroy(&ds_lists[*ds_next_idx]); |
|
2664 | 2664 |
|
2665 | 2665 |
// add existing destinations except destination that matches group & address |
2666 | 2666 |
ds_iter_set(_ds_list, &ds_filter_dest_cb, &filter_arg); |
2667 | 2667 |
|
2668 |
- if(reindex_dests(ds_lists[*next_idx]) != 0) { |
|
2668 |
+ if(reindex_dests(ds_lists[*ds_next_idx]) != 0) { |
|
2669 | 2669 |
LM_ERR("error on reindex\n"); |
2670 | 2670 |
goto error; |
2671 | 2671 |
} |
2672 | 2672 |
|
2673 | 2673 |
_ds_list_nr = setn; |
2674 |
- *crt_idx = *next_idx; |
|
2674 |
+ *ds_crt_idx = *ds_next_idx; |
|
2675 | 2675 |
|
2676 | 2676 |
ds_log_sets(); |
2677 | 2677 |
return 0; |
2678 | 2678 |
|
2679 | 2679 |
error: |
2680 |
- ds_avl_destroy(&ds_lists[*next_idx]); |
|
2681 |
- *next_idx = *crt_idx; |
|
2680 |
+ ds_avl_destroy(&ds_lists[*ds_next_idx]); |
|
2681 |
+ *ds_next_idx = *ds_crt_idx; |
|
2682 | 2682 |
return -1; |
2683 | 2683 |
} |
2684 | 2684 |
|
... | ... |
@@ -2833,7 +2833,7 @@ int ds_update_latency(int group, str *address, int code) |
2833 | 2833 |
} |
2834 | 2834 |
|
2835 | 2835 |
/* get the index of the set */ |
2836 |
- if(ds_get_index(group, *crt_idx, &idx) != 0) { |
|
2836 |
+ if(ds_get_index(group, *ds_crt_idx, &idx) != 0) { |
|
2837 | 2837 |
LM_ERR("destination set [%d] not found\n", group); |
2838 | 2838 |
return -1; |
2839 | 2839 |
} |
... | ... |
@@ -2927,7 +2927,7 @@ int ds_get_state(int group, str *address) |
2927 | 2927 |
} |
2928 | 2928 |
|
2929 | 2929 |
/* get the index of the set */ |
2930 |
- if(ds_get_index(group, *crt_idx, &idx) != 0) { |
|
2930 |
+ if(ds_get_index(group, *ds_crt_idx, &idx) != 0) { |
|
2931 | 2931 |
LM_ERR("destination set [%d] not found\n", group); |
2932 | 2932 |
return -1; |
2933 | 2933 |
} |
... | ... |
@@ -2961,7 +2961,7 @@ int ds_update_state(sip_msg_t *msg, int group, str *address, int state, |
2961 | 2961 |
} |
2962 | 2962 |
|
2963 | 2963 |
/* get the index of the set */ |
2964 |
- if(ds_get_index(group, *crt_idx, &idx) != 0) { |
|
2964 |
+ if(ds_get_index(group, *ds_crt_idx, &idx) != 0) { |
|
2965 | 2965 |
LM_ERR("destination set [%d] not found\n", group); |
2966 | 2966 |
return -1; |
2967 | 2967 |
} |
... | ... |
@@ -3162,7 +3162,7 @@ int ds_reinit_state(int group, str *address, int state) |
3162 | 3162 |
} |
3163 | 3163 |
|
3164 | 3164 |
/* get the index of the set */ |
3165 |
- if(ds_get_index(group, *crt_idx, &idx) != 0) { |
|
3165 |
+ if(ds_get_index(group, *ds_crt_idx, &idx) != 0) { |
|
3166 | 3166 |
LM_ERR("destination set [%d] not found\n", group); |
3167 | 3167 |
return -1; |
3168 | 3168 |
} |
... | ... |
@@ -3203,7 +3203,7 @@ int ds_reinit_duid_state(int group, str *vduid, int state) |
3203 | 3203 |
} |
3204 | 3204 |
|
3205 | 3205 |
/* get the index of the set */ |
3206 |
- if(ds_get_index(group, *crt_idx, &idx) != 0) { |
|
3206 |
+ if(ds_get_index(group, *ds_crt_idx, &idx) != 0) { |
|
3207 | 3207 |
LM_ERR("destination set [%d] not found\n", group); |
3208 | 3208 |
return -1; |
3209 | 3209 |
} |
... | ... |
@@ -3244,7 +3244,7 @@ int ds_reinit_state_all(int group, int state) |
3244 | 3244 |
} |
3245 | 3245 |
|
3246 | 3246 |
/* get the index of the set */ |
3247 |
- if(ds_get_index(group, *crt_idx, &idx) != 0) { |
|
3247 |
+ if(ds_get_index(group, *ds_crt_idx, &idx) != 0) { |
|
3248 | 3248 |
LM_ERR("destination set [%d] not found\n", group); |
3249 | 3249 |
return -1; |
3250 | 3250 |
} |
... | ... |
@@ -1635,10 +1635,10 @@ static void dispatcher_rpc_list(rpc_t *rpc, void *ctx) |
1635 | 1635 |
void *th; |
1636 | 1636 |
void *ih; |
1637 | 1637 |
|
1638 |
- ds_set_t *ds_list = ds_get_list(); |
|
1639 |
- int ds_list_nr = ds_get_list_nr(); |
|
1638 |
+ ds_set_t *dslist = ds_get_list(); |
|
1639 |
+ int dslistnr = ds_get_list_nr(); |
|
1640 | 1640 |
|
1641 |
- if(ds_list == NULL || ds_list_nr <= 0) { |
|
1641 |
+ if(dslist == NULL || dslistnr <= 0) { |
|
1642 | 1642 |
LM_DBG("no destination sets\n"); |
1643 | 1643 |
rpc->fault(ctx, 500, "No Destination Sets"); |
1644 | 1644 |
return; |
... | ... |
@@ -1649,12 +1649,12 @@ static void dispatcher_rpc_list(rpc_t *rpc, void *ctx) |
1649 | 1649 |
rpc->fault(ctx, 500, "Internal error root reply"); |
1650 | 1650 |
return; |
1651 | 1651 |
} |
1652 |
- if(rpc->struct_add(th, "d[", "NRSETS", ds_list_nr, "RECORDS", &ih) < 0) { |
|
1652 |
+ if(rpc->struct_add(th, "d[", "NRSETS", dslistnr, "RECORDS", &ih) < 0) { |
|
1653 | 1653 |
rpc->fault(ctx, 500, "Internal error sets structure"); |
1654 | 1654 |
return; |
1655 | 1655 |
} |
1656 | 1656 |
|
1657 |
- ds_rpc_print_set(ds_list, rpc, ctx, ih); |
|
1657 |
+ ds_rpc_print_set(dslist, rpc, ctx, ih); |
|
1658 | 1658 |
|
1659 | 1659 |
return; |
1660 | 1660 |
} |