summaryrefslogtreecommitdiff
path: root/source4/smbd/process_standard.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-29 07:00:14 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:00 -0500
commit0caeda53d37740d18b38e6d37d0ecef8c6336820 (patch)
tree52ca50fa644464ca50f1a6c14b83b8ce19b3d2d5 /source4/smbd/process_standard.c
parentbc24603e41804a1d54ff85f9114f0288a03483fa (diff)
downloadsamba-0caeda53d37740d18b38e6d37d0ecef8c6336820.tar.gz
samba-0caeda53d37740d18b38e6d37d0ecef8c6336820.tar.bz2
samba-0caeda53d37740d18b38e6d37d0ecef8c6336820.zip
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 used to be commit f2a9bbc317ba86ebe87c3ca27a3a0192de91014d)
Diffstat (limited to 'source4/smbd/process_standard.c')
-rw-r--r--source4/smbd/process_standard.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index 106be77925..9b5547ce54 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -34,7 +34,8 @@ static void standard_model_startup(void)
/*
called when a listening socket becomes readable
*/
-static void standard_accept_connection(struct event_context *ev, struct fd_event *srv_fde, time_t t, uint16_t flags)
+static void standard_accept_connection(struct event_context *ev, struct fd_event *srv_fde,
+ time_t t, uint16_t flags)
{
NTSTATUS status;
struct socket_context *sock;
@@ -63,7 +64,11 @@ static void standard_accept_connection(struct event_context *ev, struct fd_event
/* Child code ... */
/* close all the listening sockets */
- event_remove_fd_all_handler(ev, standard_accept_connection);
+ service_close_listening_sockets(server_socket->service->srv_ctx);
+
+ /* we don't care if the dup fails, as its only a select()
+ speed optimisation */
+ socket_dup(sock);
/* tdb needs special fork handling */
if (tdb_reopen_all() == -1) {