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

Function child_init

modules/rtp.io/rtp_io.c:223–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221#include <assert.h>
222
223static int
224child_init(int rank)
225{
226 rtpproxy_is_nproc_t is_nproc_f;
227
228 is_nproc_f = (rtpproxy_is_nproc_t)find_export("rtpproxy_is_nproc", 0);
229 if (is_nproc_f == NULL) {
230 LM_ERR("rtpproxy_is_nproc() not found in the rtpproxy module\n");
231 return -1;
232 }
233 int is_nproc = is_nproc_f(NPROC_CHECK);
234 LM_INFO("rtp.io: child_init(%d), notifier: %d\n", rank, is_nproc);
235 if (rank > rpi_descp->socks->n) {
236 LM_ERR("BUG: rank is higher than the number of sockets!\n");
237 return -1;
238 }
239
240 if (!is_nproc && rtp_io_close_cnlt_nsock() != 0) {
241 LM_ERR("rtp_io_close_cnlt_nsock() failed\n");
242 return -1;
243 }
244
245 if (rank <= 0) {
246 if (rtp_io_close_cnlt_socks() != 0) {
247 LM_ERR("rtp_io_close_cnlt_socks() failed\n");
248 return -1;
249 }
250 return 0;
251 }
252
253 for (int i = 0; i < rpi_descp->socks->n; i++) {
254 if (i == rank - 1)
255 continue;
256 int *fdp = &rpi_descp->socks->holder[i * 2];
257 if (close(fdp[1]) < 0)
258 return (-1);
259 fdp[1] = -1;
260 }
261
262 return (0);
263}
264
265static int rtp_io_getchildsock(int rank)
266{

Callers

nothing calls this directly

Calls 3

find_exportFunction · 0.85
rtp_io_close_cnlt_nsockFunction · 0.85
rtp_io_close_cnlt_socksFunction · 0.85

Tested by

no test coverage detected