Author: jra Date: 2006-09-28 18:08:03 +0000 (Thu, 28 Sep 2006) New Revision: 18980
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18980 Log: 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. Modified: branches/SAMBA_3_0/source/nsswitch/winbindd.h branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c branches/SAMBA_3_0/source/nsswitch/winbindd_dual.c Changeset: Modified: branches/SAMBA_3_0/source/nsswitch/winbindd.h =================================================================== --- branches/SAMBA_3_0/source/nsswitch/winbindd.h 2006-09-28 17:08:17 UTC (rev 18979) +++ branches/SAMBA_3_0/source/nsswitch/winbindd.h 2006-09-28 18:08:03 UTC (rev 18980) @@ -169,7 +169,8 @@ 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; Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c =================================================================== --- branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c 2006-09-28 17:08:17 UTC (rev 18979) +++ branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c 2006-09-28 18:08:03 UTC (rev 18980) @@ -84,6 +84,15 @@ 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 @@ 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 @@ 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 @@ } /* 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 @@ 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); } Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_dual.c =================================================================== --- branches/SAMBA_3_0/source/nsswitch/winbindd_dual.c 2006-09-28 17:08:17 UTC (rev 18979) +++ branches/SAMBA_3_0/source/nsswitch/winbindd_dual.c 2006-09-28 18:08:03 UTC (rev 18980) @@ -613,7 +613,7 @@ 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 @@ 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 @@ if ( child->domain ) { child->domain->startup = True; + child->domain->startup_time = time(NULL); } - startup_time = time(NULL); while (1) { @@ -787,7 +786,8 @@ 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 ));
