From 809b846a4745a17bdc03f4b26ee8431de7c13240 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Tue, 16 Nov 2004 05:28:38 +0000 Subject: [PATCH] Now a kvno invocation will only open the ccache file a small number of times, but there's still excessive seeking and re-reading of data happening. * cc_retr.c (krb5_cc_retrieve_cred_seq): Temporarily clear the KRB5_TC_OPENCLOSE flag on the credentials cache while reading multiple entries from it. ticket: 2763 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16873 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/ChangeLog | 6 ++++++ src/lib/krb5/ccache/cc_retr.c | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/lib/krb5/ccache/ChangeLog b/src/lib/krb5/ccache/ChangeLog index 9fe362e51..c9e2972d5 100644 --- a/src/lib/krb5/ccache/ChangeLog +++ b/src/lib/krb5/ccache/ChangeLog @@ -1,3 +1,9 @@ +2004-11-16 Ken Raeburn + + * cc_retr.c (krb5_cc_retrieve_cred_seq): Temporarily clear the + KRB5_TC_OPENCLOSE flag on the credentials cache while reading + multiple entries from it. + 2004-11-15 Ken Raeburn * cc_file.c (krb5_fcc_get_flags): New function. diff --git a/src/lib/krb5/ccache/cc_retr.c b/src/lib/krb5/ccache/cc_retr.c index 5ddb2cc63..cadd3e5fe 100644 --- a/src/lib/krb5/ccache/cc_retr.c +++ b/src/lib/krb5/ccache/cc_retr.c @@ -193,7 +193,9 @@ krb5int_cc_creds_match_request(krb5_context context, krb5_flags whichfields, krb } static krb5_error_code -krb5_cc_retrieve_cred_seq (krb5_context context, krb5_ccache id, krb5_flags whichfields, krb5_creds *mcreds, krb5_creds *creds, int nktypes, krb5_enctype *ktypes) +krb5_cc_retrieve_cred_seq (krb5_context context, krb5_ccache id, + krb5_flags whichfields, krb5_creds *mcreds, + krb5_creds *creds, int nktypes, krb5_enctype *ktypes) { /* This function could be considerably faster if it kept indexing */ /* information.. sounds like a "next version" idea to me. :-) */ @@ -206,11 +208,20 @@ krb5_cc_retrieve_cred_seq (krb5_context context, krb5_ccache id, krb5_flags whic int pref; } fetched, best; int have_creds = 0; + krb5_flags oflags = 0; #define fetchcreds (fetched.creds) - kret = krb5_cc_start_seq_get(context, id, &cursor); + kret = krb5_cc_get_flags(context, id, &oflags); if (kret != KRB5_OK) return kret; + if (oflags & KRB5_TC_OPENCLOSE) + (void) krb5_cc_set_flags(context, id, oflags & ~KRB5_TC_OPENCLOSE); + kret = krb5_cc_start_seq_get(context, id, &cursor); + if (kret != KRB5_OK) { + if (oflags & KRB5_TC_OPENCLOSE) + krb5_cc_set_flags(context, id, oflags); + return kret; + } while ((kret = krb5_cc_next_cred(context, id, &cursor, &fetchcreds)) == KRB5_OK) { if (krb5int_cc_creds_match_request(context, whichfields, mcreds, &fetchcreds)) @@ -231,6 +242,8 @@ krb5_cc_retrieve_cred_seq (krb5_context context, krb5_ccache id, krb5_flags whic } else { krb5_cc_end_seq_get(context, id, &cursor); *creds = fetchcreds; + if (oflags & KRB5_TC_OPENCLOSE) + krb5_cc_set_flags(context, id, oflags); return KRB5_OK; } } @@ -241,6 +254,8 @@ krb5_cc_retrieve_cred_seq (krb5_context context, krb5_ccache id, krb5_flags whic /* If we get here, a match wasn't found */ krb5_cc_end_seq_get(context, id, &cursor); + if (oflags & KRB5_TC_OPENCLOSE) + krb5_cc_set_flags(context, id, oflags); if (have_creds) { *creds = best.creds; return KRB5_OK; -- 2.26.2