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

Function mi_reload_rtpengines

modules/rtpengine/rtpengine.c:1397–1502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1395}
1396
1397static mi_response_t *mi_reload_rtpengines(const mi_params_t *params,
1398 struct mi_handler *async_hdl)
1399{
1400 str type;
1401 int soft_reload = 0;
1402 struct rtpe_set *crt_list, *next_list;
1403 struct rtpe_node *crt_rtpe, *next_rtpe;
1404
1405 if(db_url.s == NULL) {
1406 LM_ERR("Dynamic loading of rtpengines not enabled\n");
1407 return init_mi_error(400, MI_SSTR("Dynamic loading not enabled"));
1408 }
1409
1410 if (try_get_mi_string_param(params, "type", &type.s, &type.len) == 0) {
1411 if (!str_strcmp(&type, _str("soft")))
1412 soft_reload = 1;
1413 }
1414
1415 lock_start_write(rtpe_lock);
1416
1417 if (soft_reload) {
1418 /*
1419 soft reload:
1420 - mark all nodes/sets for teardown; as nodes are added
1421 from the database, this flag is cleared and sockets
1422 will be reused
1423 */
1424 if (*rtpe_set_list) {
1425 for(crt_list = (*rtpe_set_list)->rset_first; crt_list != NULL;
1426 crt_list = crt_list->rset_next){
1427 crt_list->set_flags |= RTPE_TEARDOWN_SET;
1428 for(crt_rtpe = crt_list->rn_first; crt_rtpe != NULL;
1429 crt_rtpe = crt_rtpe->rn_next)
1430 crt_rtpe->rn_flags |= RTPE_TEARDOWN_NODE;
1431 }
1432 }
1433
1434 if(_add_rtpengine_from_database() < 0)
1435 goto error;
1436
1437 /* remove old sets/nodes */
1438 for(crt_list = (*rtpe_set_list)->rset_first; crt_list != NULL; ){
1439 if (crt_list->set_flags&RTPE_TEARDOWN_SET) {
1440 next_list = crt_list->rset_next;
1441 free_rtpe_set(crt_list->id_set);
1442 crt_list = next_list;
1443 continue;
1444 }
1445 for(crt_rtpe = crt_list->rn_first; crt_rtpe != NULL; ){
1446 if (crt_rtpe->rn_flags&RTPE_TEARDOWN_NODE) {
1447 next_rtpe = crt_rtpe->rn_next;
1448 free_rtpe_node(crt_list, &crt_rtpe->rn_url);
1449 crt_rtpe = next_rtpe;
1450 continue;
1451 }
1452 crt_rtpe = crt_rtpe->rn_next;
1453 }
1454 crt_list = crt_list->rset_next;

Callers

nothing calls this directly

Calls 11

init_mi_errorFunction · 0.85
try_get_mi_string_paramFunction · 0.85
_strClass · 0.85
free_rtpe_setFunction · 0.85
free_rtpe_nodeFunction · 0.85
free_rtpe_nodesFunction · 0.85
select_rtpe_setFunction · 0.85
add_rtpengine_versionFunction · 0.85
update_rtpenginesFunction · 0.85

Tested by

no test coverage detected