Fix logic bug introduce in backport of ccache_regain_all_now, sync with
authorJeremy Allison <jra@samba.org>
Sun, 11 Jan 2009 04:04:27 +0000 (20:04 -0800)
committerJeremy Allison <jra@samba.org>
Sun, 11 Jan 2009 04:04:27 +0000 (20:04 -0800)
3.3 implementation.
Jeremy.

source/nsswitch/winbindd_cred_cache.c

index a0f72379d1717b319ddf4b0f63cc25fd909ef251..7b215a55ab4ccb19580ef258d3ed3e3e184da59c 100644 (file)
@@ -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;
 }