From: Jeremy Allison Date: Sun, 11 Jan 2009 04:04:27 +0000 (-0800) Subject: Fix logic bug introduce in backport of ccache_regain_all_now, sync with X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab29d6c6d349352db017d3046aeaee59e33745f4;p=thirdparty%2Fsamba.git Fix logic bug introduce in backport of ccache_regain_all_now, sync with 3.3 implementation. Jeremy. --- diff --git a/source/nsswitch/winbindd_cred_cache.c b/source/nsswitch/winbindd_cred_cache.c index a0f72379d17..7b215a55ab4 100644 --- a/source/nsswitch/winbindd_cred_cache.c +++ b/source/nsswitch/winbindd_cred_cache.c @@ -100,25 +100,32 @@ void ccache_regain_all_now(void) struct WINBINDD_CCACHE_ENTRY *cur; struct timeval t = timeval_current(); - cur = ccache_list; - while (cur) { - TALLOC_FREE(cur->event); - if (cur->refresh_time) { - cur->event = event_add_timed(winbind_event_context(), - cur, t, - "krb5_ticket_refresh_handler", - krb5_ticket_refresh_handler, - cur); + for (cur = ccache_list; cur; cur = cur->next) { + struct timed_event *new_event; + + /* + * if refresh_time is 0, we know that the + * the event has the krb5_ticket_gain_handler + */ + if (cur->refresh_time == 0) { + new_event = event_add_timed(winbind_event_context(), + cur, t, + "krb5_ticket_gain_handler", + krb5_ticket_gain_handler, + cur); } else { - cur->event = event_add_timed(winbind_event_context(), - cur, t, - "krb5_ticket_gain_handler", - krb5_ticket_gain_handler, - cur); + new_event = event_add_timed(winbind_event_context(), + cur, t, + "krb5_ticket_refresh_handler", + krb5_ticket_refresh_handler, + cur); } - if (!cur->event) { - DEBUG(0, ("ccache_regain_all_now: out of memory!!\n")); + if (!new_event) { + continue; } + + TALLOC_FREE(cur->event); + cur->event = new_event; } return; }