mirror of
https://github.com/samba-team/samba.git
synced 2025-11-11 00:23:51 +03:00
r3356: in the standard process model we need to make sure we close all
listening sockets after the fork to prevent the child still listening on incoming requests. I have also added an optimisation where we use dup()/close() to lower the file descriptor number of the new socket to the lowest possible after closing our listening sockets. This keeps the max fd num passed to select() low, which makes a difference to the speed of select().
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
84762a5976
commit
f2a9bbc317
@@ -260,6 +260,28 @@ int socket_get_fd(struct socket_context *sock)
|
||||
return sock->ops->get_fd(sock);
|
||||
}
|
||||
|
||||
/*
|
||||
call dup() on a socket, and close the old fd. This is used to change
|
||||
the fd to the lowest available number, to make select() more
|
||||
efficient (select speed depends on the maxiumum fd number passed to
|
||||
it)
|
||||
*/
|
||||
NTSTATUS socket_dup(struct socket_context *sock)
|
||||
{
|
||||
int fd;
|
||||
if (sock->fd == -1) {
|
||||
return NT_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
fd = dup(sock->fd);
|
||||
if (fd == -1) {
|
||||
return map_nt_error_from_unix(errno);
|
||||
}
|
||||
close(sock->fd);
|
||||
sock->fd = fd;
|
||||
return NT_STATUS_OK;
|
||||
|
||||
}
|
||||
|
||||
const struct socket_ops *socket_getops_byname(const char *name, enum socket_type type)
|
||||
{
|
||||
if (strcmp("ip", name) == 0 ||
|
||||
|
||||
Reference in New Issue
Block a user