From ab29d6c6d349352db017d3046aeaee59e33745f4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 10 Jan 2009 20:04:27 -0800 Subject: [PATCH] Fix logic bug introduce in backport of ccache_regain_all_now, sync with 3.3 implementation. Jeremy. --- source/nsswitch/winbindd_cred_cache.c | 39 ++++++++++++++++----------- 1 file changed, 23 insertions(+), 16 deletions(-) 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; } -- 2.47.2