svn commit: samba r7301 - in trunk/source/nsswitch: .
vlendec at samba.org
vlendec at samba.org
Sun Jun 5 11:01:01 GMT 2005
Author: vlendec
Date: 2005-06-05 11:01:00 +0000 (Sun, 05 Jun 2005)
New Revision: 7301
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7301
Log:
First attempt at restarting died winbind child processes.
Volker
Modified:
trunk/source/nsswitch/winbindd.c
trunk/source/nsswitch/winbindd.h
trunk/source/nsswitch/winbindd_dual.c
trunk/source/nsswitch/winbindd_sid.c
Changeset:
Modified: trunk/source/nsswitch/winbindd.c
===================================================================
--- trunk/source/nsswitch/winbindd.c 2005-06-05 08:53:03 UTC (rev 7300)
+++ trunk/source/nsswitch/winbindd.c 2005-06-05 11:01:00 UTC (rev 7301)
@@ -202,14 +202,11 @@
sys_select_signal();
}
+static BOOL do_sigchld;
+
static void sigchld_handler(int signum)
{
- pid_t pid;
- int status;
-
- while ((pid = wait(&status)) != -1 || errno == EINTR) {
- continue; /* Reap children */
- }
+ do_sigchld = True;
sys_select_signal();
}
@@ -878,6 +875,16 @@
print_winbindd_status();
do_sigusr2 = False;
}
+
+ if (do_sigchld) {
+ pid_t pid;
+
+ do_sigchld = False;
+
+ while ((pid = sys_waitpid(-1, NULL, WNOHANG)) > 0) {
+ winbind_child_died(pid);
+ }
+ }
}
/* Main function */
@@ -1047,11 +1054,7 @@
init_domain_list();
- if (!init_idmap_child()) {
- DEBUG(1, ("Could not init idmap child -- "
- "netlogon proxy only\n"));
- idmap_set_proxyonly();
- }
+ init_idmap_child();
/* Loop waiting for requests */
Modified: trunk/source/nsswitch/winbindd.h
===================================================================
--- trunk/source/nsswitch/winbindd.h 2005-06-05 08:53:03 UTC (rev 7300)
+++ trunk/source/nsswitch/winbindd.h 2005-06-05 11:01:00 UTC (rev 7301)
@@ -138,7 +138,12 @@
/* Async child */
struct winbindd_child {
+ struct winbindd_child *next, *prev;
+
pid_t pid;
+ struct winbindd_domain *domain;
+ pstring logfilename;
+
struct fd_event event;
struct winbindd_async_request *requests;
};
Modified: trunk/source/nsswitch/winbindd_dual.c
===================================================================
--- trunk/source/nsswitch/winbindd_dual.c 2005-06-05 08:53:03 UTC (rev 7300)
+++ trunk/source/nsswitch/winbindd_dual.c 2005-06-05 11:01:00 UTC (rev 7301)
@@ -305,7 +305,7 @@
talloc_get_type_abort(private, struct winbindd_async_request);
if (!success) {
- DEBUG(5, ("Could not send async request"));
+ DEBUG(5, ("Could not send async request\n"));
state->response->length = sizeof(struct winbindd_response);
state->response->result = WINBINDD_ERROR;
@@ -345,19 +345,36 @@
state->continuation(state->private, True);
}
+static BOOL fork_domain_child(struct winbindd_child *child);
+
static void schedule_async_request(struct winbindd_child *child)
{
struct winbindd_async_request *request = child->requests;
- if (request == NULL)
+ if (request == NULL) {
return;
+ }
- if (child->event.flags != 0)
+ if (child->event.flags != 0) {
return; /* Busy */
+ }
+ if ((child->pid == 0) && (!fork_domain_child(child))) {
+ /* Cancel all outstanding requests */
+
+ while (request != NULL) {
+ /* request might be free'd in the continuation */
+ struct winbindd_async_request *next = request->next;
+ request->continuation(request->private, False);
+ request = next;
+ }
+ return;
+ }
+
setup_async_write(&child->event, request->request,
sizeof(*request->request),
async_request_sent, request);
+ return;
}
struct domain_request_state {
@@ -496,27 +513,56 @@
talloc_destroy(state->mem_ctx);
}
-BOOL setup_domain_child(struct winbindd_domain *domain,
+void setup_domain_child(struct winbindd_domain *domain,
struct winbindd_child *child,
const char *explicit_logfile)
{
- int fdpair[2];
- struct winbindd_cli_state state;
-
- extern BOOL override_logfile;
- pstring logfilename;
-
if (explicit_logfile != NULL) {
- pstr_sprintf(logfilename, "%s/log.winbindd-%s",
+ pstr_sprintf(child->logfilename, "%s/log.winbindd-%s",
dyn_LOGFILEBASE, explicit_logfile);
} else if (domain != NULL) {
- pstr_sprintf(logfilename, "%s/log.wb-%s",
+ pstr_sprintf(child->logfilename, "%s/log.wb-%s",
dyn_LOGFILEBASE, domain->name);
} else {
smb_panic("Internal error: domain == NULL && "
"explicit_logfile == NULL");
}
+ child->domain = domain;
+}
+
+struct winbindd_child *children = NULL;
+
+void winbind_child_died(pid_t pid)
+{
+ struct winbindd_child *child;
+
+ for (child = children; child != NULL; child = child->next) {
+ if (child->pid == pid) {
+ break;
+ }
+ }
+
+ if (child == NULL) {
+ DEBUG(0, ("Unknown child %d died!\n", pid));
+ return;
+ }
+
+ remove_fd_event(&child->event);
+ close(child->event.fd);
+ child->event.fd = 0;
+ child->event.flags = 0;
+ child->pid = 0;
+
+ schedule_async_request(child);
+}
+
+static BOOL fork_domain_child(struct winbindd_child *child)
+{
+ int fdpair[2];
+ struct winbindd_cli_state state;
+ extern BOOL override_logfile;
+
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fdpair) != 0) {
DEBUG(0, ("Could not open child pipe: %s\n",
strerror(errno)));
@@ -536,6 +582,8 @@
if (child->pid != 0) {
/* Parent */
close(fdpair[0]);
+ child->next = child->prev = NULL;
+ DLIST_ADD(children, child);
child->event.fd = fdpair[1];
child->event.flags = 0;
child->requests = NULL;
@@ -557,7 +605,7 @@
close_conns_after_fork();
if (!override_logfile) {
- lp_set_logfile(logfilename);
+ lp_set_logfile(child->logfilename);
reopen_logs();
}
@@ -583,7 +631,7 @@
(int)state.request.cmd));
state.request.null_term = '\0';
- child_process_request(domain, &state);
+ child_process_request(child->domain, &state);
if (state.response.result == WINBINDD_OK)
cache_store_response(sys_getpid(),
Modified: trunk/source/nsswitch/winbindd_sid.c
===================================================================
--- trunk/source/nsswitch/winbindd_sid.c 2005-06-05 08:53:03 UTC (rev 7300)
+++ trunk/source/nsswitch/winbindd_sid.c 2005-06-05 11:01:00 UTC (rev 7301)
@@ -131,9 +131,9 @@
static struct winbindd_child static_idmap_child;
-BOOL init_idmap_child(void)
+void init_idmap_child(void)
{
- return setup_domain_child(NULL, &static_idmap_child, "idmap");
+ setup_domain_child(NULL, &static_idmap_child, "idmap");
}
struct winbindd_child *idmap_child(void)
More information about the samba-cvs
mailing list