comparison rtp-mgr/ctrl_prot.c @ 180:565477d07418

themwi-rtp-mgr: close file descriptors after sending them across
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 Mar 2023 20:41:23 -0800
parents b79d6334f543
children 3962d9345a09
comparison
equal deleted inserted replaced
179:b79d6334f543 180:565477d07418
18 #include "struct.h" 18 #include "struct.h"
19 #include "select.h" 19 #include "select.h"
20 20
21 extern struct bind_range_cfg bind_range_gsm, bind_range_pstn; 21 extern struct bind_range_cfg bind_range_gsm, bind_range_pstn;
22 22
23 void 23 static void
24 free_rtp_end(roe) 24 free_rtp_end(roe)
25 struct rtp_one_end *roe; 25 struct rtp_one_end *roe;
26 { 26 {
27 close(roe->rtp_fd); 27 close(roe->rtp_fd);
28 close(roe->rtcp_fd); 28 close(roe->rtcp_fd);
29 }
30
31 static void
32 close_fds(fd_list, num_fd)
33 int *fd_list, num_fd;
34 {
35 int i;
36
37 for (i = 0; i < num_fd; i++)
38 close(fd_list[i]);
29 } 39 }
30 40
31 void 41 void
32 ctrl_message_handler(fd) 42 ctrl_message_handler(fd)
33 { 43 {
125 cmsg->cmsg_type = SCM_RIGHTS; 135 cmsg->cmsg_type = SCM_RIGHTS;
126 cmsg->cmsg_len = CMSG_LEN(sizeof(int) * num_fd); 136 cmsg->cmsg_len = CMSG_LEN(sizeof(int) * num_fd);
127 fd_bufptr = (int *) CMSG_DATA(cmsg); 137 fd_bufptr = (int *) CMSG_DATA(cmsg);
128 bcopy(fd_out, fd_bufptr, sizeof(int) * num_fd); 138 bcopy(fd_out, fd_bufptr, sizeof(int) * num_fd);
129 sendmsg(fd, &msg, 0); 139 sendmsg(fd, &msg, 0);
140 close_fds(fd_out, num_fd);
130 } 141 }