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

Function _ds_set_state

modules/dispatcher/dispatch.c:2250–2359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2248static str active_str = str_init("active");
2249
2250static void _ds_set_state(ds_set_p set, int idx, str *address, int state,
2251 int type, ds_partition_t *partition, int do_repl, int raise_event,
2252 char *reason_s, int reason_len)
2253{
2254 evi_params_p list = NULL;
2255 int old_flags;
2256 str reason = {reason_s, reason_len};
2257
2258 /* remove the Probing/Inactive-State? Set the fail-count to 0. */
2259 if (state == DS_PROBING_DST) {
2260 if (type) {
2261 if (set->dlist[idx].flags & DS_INACTIVE_DST) {
2262 LM_INFO("Ignoring the request to set this destination"
2263 " to probing: It is already inactive!\n");
2264 return;
2265 }
2266
2267 if (do_repl) {
2268 set->dlist[idx].failure_count++;
2269 /* Fire only, if the Threshold is reached. */
2270 if (set->dlist[idx].failure_count
2271 < probing_threshold)
2272 return;
2273
2274 if (set->dlist[idx].failure_count
2275 > probing_threshold)
2276 set->dlist[idx].failure_count
2277 = probing_threshold;
2278 }
2279 }
2280 }
2281 /* Reset the Failure-Counter */
2282 if ((state & DS_RESET_FAIL_DST) > 0) {
2283 set->dlist[idx].failure_count = 0;
2284 state &= ~DS_RESET_FAIL_DST;
2285 }
2286
2287 /* set the new state of the destination */
2288 old_flags = set->dlist[idx].flags;
2289 if(type)
2290 set->dlist[idx].flags |= state;
2291 else
2292 set->dlist[idx].flags &= ~state;
2293
2294 if ( set->dlist[idx].flags != old_flags) {
2295
2296 /* state actually changed -> do all updates */
2297 set->dlist[idx].flags |= DS_STATE_DIRTY_DST;
2298
2299 /* replicate the change of status */
2300 if (do_repl) replicate_ds_status_event( &partition->name,
2301 set->id, address, state, type);
2302
2303 /* update info on active destinations */
2304 if ( ((old_flags&(DS_PROBING_DST|DS_INACTIVE_DST))?0:1) !=
2305 ((set->dlist[idx].flags&(DS_PROBING_DST|DS_INACTIVE_DST))?0:1) )
2306 /* this destination switched state between
2307 * disabled <> enabled -> update active info */

Callers 1

ds_set_stateFunction · 0.85

Calls 7

re_calculate_active_dstsFunction · 0.85
sr_add_report_fmtFunction · 0.85
evi_probe_eventFunction · 0.85
evi_get_paramsFunction · 0.85
evi_free_paramsFunction · 0.85
evi_raise_eventFunction · 0.85

Tested by

no test coverage detected