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

Function update_rtpengines

modules/rtpengine/rtpengine.c:1938–2003  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1936}
1937
1938static int update_rtpengines(int force_test)
1939{
1940 int *tmp_socks;
1941 int i, reset=0;
1942 struct rtpe_set * crt_list;
1943 struct rtpe_node * crt_rtpe;
1944 struct rtpe_version * crt_version;
1945
1946 LM_DBG("updating list from %d to %d [%d]\n", my_version, *list_version, rtpe_number);
1947
1948 if (*rtpe_versions==NULL || (*rtpe_versions)->version_last==NULL
1949 || my_version == (*rtpe_versions)->version_last->version)
1950 return 0; /* nothing to do or already updated */
1951
1952 for (crt_version = (*rtpe_versions)->version_first; crt_version != NULL;
1953 crt_version = crt_version->version_next) {
1954 if (crt_version->version <= my_version)
1955 continue;
1956 if (crt_version->version_flags&RTPE_TEARDOWN_SOCKETS)
1957 reset = 1;
1958 my_version = crt_version->version;
1959 }
1960
1961 if (myrank < *child_versions_no)
1962 child_versions[myrank] = my_version;
1963 else
1964 LM_BUG("rank overflow %d vs %d\n", myrank, *child_versions_no);
1965
1966 /*
1967 close all sockets if any versions required
1968 a hard reload of rtpengine nodes
1969 */
1970 if (reset) {
1971 for (i = 0; i < rtpe_number; i++)
1972 disconnect_rtpe_socket(i);
1973 return connect_rtpengines(force_test);
1974 }
1975
1976 /*
1977 only close sockets that were removed from set(s)
1978 */
1979 tmp_socks = (int*)pkg_malloc(rtpe_number * sizeof(int));
1980 if (tmp_socks == NULL) {
1981 LM_ERR("no more pkg memory\n");
1982 return -1;
1983 }
1984 memcpy(tmp_socks, rtpe_socks, rtpe_number * sizeof(int));
1985
1986 for(crt_list = (*rtpe_set_list)->rset_first; crt_list != NULL;
1987 crt_list = crt_list->rset_next){
1988 for(crt_rtpe = crt_list->rn_first; crt_rtpe != NULL;
1989 crt_rtpe = crt_rtpe->rn_next) {
1990 if (crt_rtpe->idx < rtpe_number)
1991 tmp_socks[crt_rtpe->idx] = 0; /* mark as active */
1992 }
1993 }
1994
1995 for (i = 0; i < rtpe_number; i++) {

Callers 4

mi_reload_rtpenginesFunction · 0.85
rtpengine_timerFunction · 0.85
get_rtpe_nodeFunction · 0.85
select_rtpe_nodeFunction · 0.85

Calls 2

disconnect_rtpe_socketFunction · 0.85
connect_rtpenginesFunction · 0.85

Tested by

no test coverage detected