| 2359 | } |
| 2360 | |
| 2361 | int ds_set_state(int group, str *address, int state, int type, |
| 2362 | ds_partition_t *partition, int do_repl, int is_sync, |
| 2363 | char *status_s, int status_len) |
| 2364 | { |
| 2365 | int i=0; |
| 2366 | ds_set_p idx = NULL; |
| 2367 | |
| 2368 | if ( (*partition->data)->sets==NULL ){ |
| 2369 | LM_DBG("empty destination set\n"); |
| 2370 | return -1; |
| 2371 | } |
| 2372 | |
| 2373 | /* access ds data under reader's lock */ |
| 2374 | lock_start_read( partition->lock ); |
| 2375 | |
| 2376 | /* get the index of the set */ |
| 2377 | if(ds_get_index(group, &idx, partition)!=0) { |
| 2378 | LM_ERR("destination set [%d] not found\n", group); |
| 2379 | lock_stop_read( partition->lock ); |
| 2380 | return -1; |
| 2381 | } |
| 2382 | |
| 2383 | while(i<idx->nr) |
| 2384 | { |
| 2385 | if(idx->dlist[i].uri.len==address->len |
| 2386 | && strncasecmp(idx->dlist[i].uri.s, address->s, |
| 2387 | address->len)==0) |
| 2388 | { |
| 2389 | if (is_sync) { |
| 2390 | if ((idx->dlist[i].flags & (DS_INACTIVE_DST|DS_PROBING_DST)) != |
| 2391 | (state & (DS_INACTIVE_DST|DS_PROBING_DST))) { |
| 2392 | /* status has changed */ |
| 2393 | if (state & DS_INACTIVE_DST) { |
| 2394 | _ds_set_state(idx, i, address, DS_INACTIVE_DST, 1, |
| 2395 | partition, 0, 0, CHAR_INT_NULL); |
| 2396 | _ds_set_state(idx, i, address, DS_PROBING_DST, 0, |
| 2397 | partition, 0, 0, CHAR_INT_NULL); |
| 2398 | } else if (state & DS_PROBING_DST) { |
| 2399 | _ds_set_state(idx, i, address, DS_PROBING_DST, 1, |
| 2400 | partition, 0, 0, CHAR_INT_NULL); |
| 2401 | _ds_set_state(idx, i, address, DS_INACTIVE_DST, 0, |
| 2402 | partition, 0, 0, CHAR_INT_NULL); |
| 2403 | } else { /* set active */ |
| 2404 | _ds_set_state(idx, i, address, |
| 2405 | DS_INACTIVE_DST|DS_PROBING_DST, 0, partition, 0, 0, |
| 2406 | CHAR_INT_NULL); |
| 2407 | } |
| 2408 | } |
| 2409 | } else |
| 2410 | _ds_set_state(idx, i, address, state, type, partition, |
| 2411 | do_repl, 1, status_s, status_len); |
| 2412 | |
| 2413 | lock_stop_read( partition->lock ); |
| 2414 | return 0; |
| 2415 | } |
| 2416 | i++; |
| 2417 | } |
| 2418 |
no test coverage detected