From 0757688eb34ec1a22bf8c28f72416d6684756647 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 28 Apr 2011 13:26:57 +0200 Subject: [PATCH] s3: In winbind, close parent/child sockets This should further reduce fd load in winbind children --- source3/winbindd/winbindd.c | 2 +- source3/winbindd/winbindd_cm.c | 2 +- source3/winbindd/winbindd_dual.c | 13 +++++++++++-- source3/winbindd/winbindd_proto.h | 3 ++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 033c436c88b..232f9b4c60f 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -404,7 +404,7 @@ static void winbind_msg_validate_cache(struct messaging_context *msg_ctx, /* child */ - if (!winbindd_reinit_after_fork(NULL)) { + if (!winbindd_reinit_after_fork(NULL, NULL)) { _exit(0); } diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index 06d954fe952..f065d839950 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -233,7 +233,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain) } } - if (!winbindd_reinit_after_fork(lfile)) { + if (!winbindd_reinit_after_fork(NULL, lfile)) { messaging_send_buf(winbind_messaging_context(), pid_to_procid(parent_pid), MSG_WINBIND_FAILED_TO_GO_ONLINE, diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 04ef3d80515..47ab6c17b70 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -1167,7 +1167,8 @@ static void child_msg_dump_event_list(struct messaging_context *msg, dump_event_list(winbind_event_context()); } -bool winbindd_reinit_after_fork(const char *logfilename) +bool winbindd_reinit_after_fork(const struct winbindd_child *myself, + const char *logfilename) { struct winbindd_domain *domain; struct winbindd_child *cl; @@ -1242,6 +1243,14 @@ bool winbindd_reinit_after_fork(const char *logfilename) * go through the parent. */ cl->pid = (pid_t)0; + + /* + * Close service sockets to all other children + */ + if ((cl != myself) && (cl->sock != -1)) { + close(cl->sock); + cl->sock = -1; + } } /* * This is a little tricky, children must not @@ -1325,7 +1334,7 @@ static bool fork_domain_child(struct winbindd_child *child) state.sock = fdpair[0]; close(fdpair[1]); - if (!winbindd_reinit_after_fork(child->logfilename)) { + if (!winbindd_reinit_after_fork(child, child->logfilename)) { _exit(0); } diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index 5b48a99a8fb..725bf6f8a70 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -291,7 +291,8 @@ void winbind_msg_ip_dropped_parent(struct messaging_context *msg_ctx, uint32_t msg_type, struct server_id server_id, DATA_BLOB *data); -bool winbindd_reinit_after_fork(const char *logfilename); +bool winbindd_reinit_after_fork(const struct winbindd_child *myself, + const char *logfilename); struct winbindd_domain *wb_child_domain(void); /* The following definitions come from winbindd/winbindd_group.c */ -- 2.34.1