mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 18:25:07 -05:00
socket: provide function for closing reusable sockets
This commit is contained in:
20
socket.c
20
socket.c
@@ -1336,16 +1336,11 @@ SCK_Initialise(int family)
|
|||||||
void
|
void
|
||||||
SCK_Finalise(void)
|
SCK_Finalise(void)
|
||||||
{
|
{
|
||||||
int fd;
|
|
||||||
|
|
||||||
ARR_DestroyInstance(recv_sck_messages);
|
ARR_DestroyInstance(recv_sck_messages);
|
||||||
ARR_DestroyInstance(recv_headers);
|
ARR_DestroyInstance(recv_headers);
|
||||||
ARR_DestroyInstance(recv_messages);
|
ARR_DestroyInstance(recv_messages);
|
||||||
|
|
||||||
for (fd = first_reusable_fd; fd < first_reusable_fd + reusable_fds; fd++)
|
SCK_CloseReusableSockets();
|
||||||
close(fd);
|
|
||||||
reusable_fds = 0;
|
|
||||||
first_reusable_fd = 0;
|
|
||||||
|
|
||||||
initialised = 0;
|
initialised = 0;
|
||||||
}
|
}
|
||||||
@@ -1495,6 +1490,19 @@ SCK_IsReusable(int fd)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
SCK_CloseReusableSockets(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
for (fd = first_reusable_fd; fd < first_reusable_fd + reusable_fds; fd++)
|
||||||
|
close(fd);
|
||||||
|
reusable_fds = 0;
|
||||||
|
first_reusable_fd = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
int
|
int
|
||||||
SCK_SetIntOption(int sock_fd, int level, int name, int value)
|
SCK_SetIntOption(int sock_fd, int level, int name, int value)
|
||||||
{
|
{
|
||||||
|
|||||||
3
socket.h
3
socket.h
@@ -112,6 +112,9 @@ extern int SCK_OpenUnixSocketPair(int flags, int *other_fd);
|
|||||||
/* Check if a file descriptor was passed from the service manager */
|
/* Check if a file descriptor was passed from the service manager */
|
||||||
extern int SCK_IsReusable(int sock_fd);
|
extern int SCK_IsReusable(int sock_fd);
|
||||||
|
|
||||||
|
/* Close all reusable sockets before finalisation (e.g. in a helper process) */
|
||||||
|
extern void SCK_CloseReusableSockets(void);
|
||||||
|
|
||||||
/* Set and get a socket option of int size */
|
/* Set and get a socket option of int size */
|
||||||
extern int SCK_SetIntOption(int sock_fd, int level, int name, int value);
|
extern int SCK_SetIntOption(int sock_fd, int level, int name, int value);
|
||||||
extern int SCK_GetIntOption(int sock_fd, int level, int name, int *value);
|
extern int SCK_GetIntOption(int sock_fd, int level, int name, int *value);
|
||||||
|
|||||||
Reference in New Issue
Block a user