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

Function mod_init

modules/rtp.io/rtp_io.c:140–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140static int mod_init(void)
141{
142 int nsocks;
143 const char * const argv_stat[] = {
144 "-d", "err",
145 "-n", "tcp:127.0.0.1:9642",
146 "--dso", "catch_dtmf",
147 "--dso", "dtls_gw",
148 "--dso", "ice_lite",
149 };
150
151 unsigned int extra = 0;
152 nsocks = count_child_processes() - count_module_procs(0) - timer_count_processes(&extra);
153 nsocks -= extra;
154
155 if (nsocks <= 1)
156 goto e0;
157
158 LM_DBG("initializing %s(%d)\n", exports.name, nsocks);
159
160 if (rio_socks_init(nsocks) != 0)
161 goto e0;
162 if (init_rtpp_host() != 0)
163 goto e1;
164
165 for (int i = 0; i < howmany(argv_stat, *argv_stat); i++) {
166 ENV_ADD(argv_stat[i], e1);
167 }
168
169 struct rtpp_n_sock *n_sock = &rpi_descp->n_sock;
170 int *fdp = n_sock->_fds;
171 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fdp) < 0)
172 goto e1;
173 snprintf(n_sock->_name, sizeof(n_sock->_name), "fd:%d", n_sock->fds.rtpp);
174 n_sock->name.s = n_sock->_name;
175 n_sock->name.len = strlen(n_sock->_name);
176 ENV_ADD("-n", e2);
177 ENV_ADD("%s", e2, n_sock->name.s);
178 for (int i = 0; i < nsocks; i++) {
179 int *fdp = &rpi_descp->socks->holder[i * 2];
180 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fdp) < 0)
181 goto e2;
182 ENV_ADD("-s", e2);
183 ENV_ADD("fd:%d", e2, fdp[0]);
184 }
185
186 rpi_descp->socks->n = nsocks;
187
188 return 0;
189e2:
190 close(n_sock->_fds[0]);
191 close(n_sock->_fds[1]);
192e1:
193 free(rpi_descp->socks);
194e0:
195 return -1;
196}
197

Callers

nothing calls this directly

Calls 5

count_child_processesFunction · 0.85
count_module_procsFunction · 0.85
timer_count_processesFunction · 0.85
rio_socks_initFunction · 0.85
init_rtpp_hostFunction · 0.85

Tested by

no test coverage detected