summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-09-28 18:08:03 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:14:52 -0500
commit0f56237bc0e0da61c958eb964b6a02958e0d5cda (patch)
treedae01139eea090f7460c6c99466e08e6f60e57fe /source3
parente07df9be38de23f054fa06da8d6bb9929fe766e1 (diff)
downloadsamba-0f56237bc0e0da61c958eb964b6a02958e0d5cda.tar.gz
samba-0f56237bc0e0da61c958eb964b6a02958e0d5cda.tar.bz2
samba-0f56237bc0e0da61c958eb964b6a02958e0d5cda.zip
r18980: Be a little more intelligent about "startup_time",
move into the domain struct. Allow message to go online to set this state and cope with removing it. Jeremy. (This used to be commit 51f0e60cc3a652b0ff1658d4c07bfc9493fbc51a)
Diffstat (limited to 'source3')
-rw-r--r--source3/nsswitch/winbindd.h3
-rw-r--r--source3/nsswitch/winbindd_cm.c27
-rw-r--r--source3/nsswitch/winbindd_dual.c8
3 files changed, 31 insertions, 7 deletions
diff --git a/source3/nsswitch/winbindd.h b/source3/nsswitch/winbindd.h
index 1437343965..c18848ac52 100644
--- a/source3/nsswitch/winbindd.h
+++ b/source3/nsswitch/winbindd.h
@@ -169,7 +169,8 @@ struct winbindd_domain {
BOOL primary; /* is this our primary domain ? */
BOOL internal; /* BUILTIN and member SAM */
BOOL online; /* is this domain available ? */
- BOOL startup; /* are we in the first 30 seconds after fork ? */
+ time_t startup_time; /* When we set "startup" true. */
+ BOOL startup; /* are we in the first 30 seconds after startup_time ? */
/* Lookup methods for this domain (LDAP or RPC) */
struct winbindd_methods *methods;
diff --git a/source3/nsswitch/winbindd_cm.c b/source3/nsswitch/winbindd_cm.c
index 3ba6f42251..43a2e286a1 100644
--- a/source3/nsswitch/winbindd_cm.c
+++ b/source3/nsswitch/winbindd_cm.c
@@ -84,6 +84,15 @@ static void check_domain_online_handler(struct timed_event *te,
TALLOC_FREE(domain->check_online_event);
}
+ /* Are we still in "startup" mode ? */
+
+ if (domain->startup && (now->tv_sec > domain->startup_time + 30)) {
+ /* No longer in "startup" mode. */
+ DEBUG(10,("check_domain_online_handler: domain %s no longer in 'startup' mode.\n",
+ domain->name ));
+ domain->startup = False;
+ }
+
/* We've been told to stay offline, so stay
that way. */
@@ -125,8 +134,13 @@ void set_domain_offline(struct winbindd_domain *domain)
return;
}
+ /* If we're in statup mode, check again in 10 seconds, not in
+ lp_winbind_cache_time() seconds (which is 5 mins by default). */
+
domain->check_online_event = add_timed_event( NULL,
- timeval_current_ofs(lp_winbind_cache_time(), 0),
+ domain->startup ?
+ timeval_current_ofs(10,0) :
+ timeval_current_ofs(lp_winbind_cache_time(), 0),
"check_domain_online_handler",
check_domain_online_handler,
domain);
@@ -161,6 +175,9 @@ static void set_domain_online(struct winbindd_domain *domain)
GetTimeOfDay(&now);
set_event_dispatch_time("krb5_ticket_gain_handler", now);
domain->online = True;
+
+ /* Ok, we're out of any startup mode now... */
+ domain->startup = False;
}
/****************************************************************
@@ -179,7 +196,8 @@ void set_domain_online_request(struct winbindd_domain *domain)
}
/* We've been told it's safe to go online and
- try and connect to a DC. But I don't believe it...
+ try and connect to a DC. But I don't believe it
+ because network manager seems to lie.
Wait at least 5 seconds. Heuristics suck... */
if (!domain->check_online_event) {
@@ -189,6 +207,11 @@ void set_domain_online_request(struct winbindd_domain *domain)
struct timeval tev;
GetTimeOfDay(&tev);
+
+ /* Go into "startup" mode again. */
+ domain->startup_time = tev.tv_sec;
+ domain->startup = True;
+
tev.tv_sec += 5;
set_event_dispatch_time("check_domain_online_handler", tev);
}
diff --git a/source3/nsswitch/winbindd_dual.c b/source3/nsswitch/winbindd_dual.c
index 317a103f33..976fff8ebe 100644
--- a/source3/nsswitch/winbindd_dual.c
+++ b/source3/nsswitch/winbindd_dual.c
@@ -613,7 +613,7 @@ static void child_msg_online(int msg_type, struct process_id src, void *buf, siz
to force a reconnect now. */
for (domain = domain_list(); domain; domain = domain->next) {
- DEBUG(5,("child_msg_online: marking %s online.\n", domain->name));
+ DEBUG(5,("child_msg_online: requesting %s to go online.\n", domain->name));
winbindd_flush_negative_conn_cache(domain);
set_domain_online_request(domain);
}
@@ -682,7 +682,6 @@ static BOOL fork_domain_child(struct winbindd_child *child)
int fdpair[2];
struct winbindd_cli_state state;
extern BOOL override_logfile;
- time_t startup_time;
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fdpair) != 0) {
DEBUG(0, ("Could not open child pipe: %s\n",
@@ -768,8 +767,8 @@ static BOOL fork_domain_child(struct winbindd_child *child)
if ( child->domain ) {
child->domain->startup = True;
+ child->domain->startup_time = time(NULL);
}
- startup_time = time(NULL);
while (1) {
@@ -787,7 +786,8 @@ static BOOL fork_domain_child(struct winbindd_child *child)
GetTimeOfDay(&now);
- if (child->domain && child->domain->startup && (now.tv_sec > startup_time + 30)) {
+ if (child->domain && child->domain->startup &&
+ (now.tv_sec > child->domain->startup_time + 30)) {
/* No longer in "startup" mode. */
DEBUG(10,("fork_domain_child: domain %s no longer in 'startup' mode.\n",
child->domain->name ));