Rewrite the building of the ccache-type linked list to be linear
authorKen Raeburn <raeburn@mit.edu>
Tue, 12 Aug 2008 22:14:39 +0000 (22:14 +0000)
committerKen Raeburn <raeburn@mit.edu>
Tue, 12 Aug 2008 22:14:39 +0000 (22:14 +0000)
instead of branched, and thus a bit easier to follow and modify.

If NO_FILE_CCACHE is defined, leave the file cache out of the list,
and (if we're not using ccapi) use the memory cache as the default.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20649 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/ccache/ccbase.c
src/lib/krb5/ccache/ccdefops.c

index 2e33dc858ad24097fbbaddef3c24c6d654e2a94e..e8bd9cec6771f6ab9ca344934488e5fcc225bb66 100644 (file)
@@ -44,43 +44,42 @@ struct krb5_cc_typecursor {
 /* typedef krb5_cc_typecursor in k5-int.h */
 
 extern const krb5_cc_ops krb5_mcc_ops;
-#ifdef USE_KEYRING_CCACHE
-extern const krb5_cc_ops krb5_krcc_ops;
-#endif
+
+#define NEXT NULL
 
 #ifdef _WIN32
 extern const krb5_cc_ops krb5_lcc_ops;
-static struct krb5_cc_typelist cc_lcc_entry = { &krb5_lcc_ops, NULL };
-static struct krb5_cc_typelist cc_mcc_entry = { &krb5_mcc_ops, &cc_lcc_entry };
-#else
+static struct krb5_cc_typelist cc_lcc_entry = { &krb5_lcc_ops, NEXT };
+#undef NEXT
+#define NEXT &cc_lcc_entry
+#endif
 
 #ifdef USE_CCAPI_V3
 extern const krb5_cc_ops krb5_cc_stdcc_ops;
-static struct krb5_cc_typelist cc_stdcc_entry = { &krb5_cc_stdcc_ops, NULL };
-static struct krb5_cc_typelist cc_mcc_entry = { &krb5_mcc_ops, &cc_stdcc_entry };
-#else
+static struct krb5_cc_typelist cc_stdcc_entry = { &krb5_cc_stdcc_ops, NEXT };
+#undef NEXT
+#define NEXT &cc_stdcc_entry
+#endif
 
-static struct krb5_cc_typelist cc_mcc_entry = { &krb5_mcc_ops, NULL };
-#endif /* USE_CCAPI_V3 */
+static struct krb5_cc_typelist cc_mcc_entry = { &krb5_mcc_ops, NEXT };
+#undef NEXT
+#define NEXT &cc_mcc_entry
+
+#ifndef NO_FILE_CCACHE
+static struct krb5_cc_typelist cc_fcc_entry = { &krb5_cc_file_ops, NEXT };
+#undef NEXT
+#define NEXT &cc_fcc_entry
+#endif
 
 #ifdef USE_KEYRING_CCACHE
-static struct krb5_cc_typelist cc_file_entry = { &krb5_cc_file_ops,
-                                                &cc_mcc_entry };
-static struct krb5_cc_typelist cc_krcc_entry = { &krb5_krcc_ops,
-                                                &cc_file_entry };
+extern const krb5_cc_ops krb5_krcc_ops;
+static struct krb5_cc_typelist cc_krcc_entry = { &krb5_krcc_ops, NEXT };
+#undef NEXT
+#define NEXT &cc_krcc_entry
 #endif /* USE_KEYRING_CCACHE */
-#endif
 
-#ifndef USE_KEYRING_CCACHE
-static struct krb5_cc_typelist cc_fcc_entry = { &krb5_cc_file_ops,
-                                               &cc_mcc_entry };
-#endif
 
-#ifdef USE_KEYRING_CCACHE
-#define INITIAL_TYPEHEAD (&cc_krcc_entry)
-#else
-#define INITIAL_TYPEHEAD (&cc_fcc_entry)
-#endif
+#define INITIAL_TYPEHEAD (NEXT)
 static struct krb5_cc_typelist *cc_typehead = INITIAL_TYPEHEAD;
 static k5_mutex_t cc_typelist_lock = K5_MUTEX_PARTIAL_INITIALIZER;
 
@@ -98,9 +97,11 @@ krb5int_cc_initialize(void)
     err = k5_mutex_finish_init(&cc_typelist_lock);
     if (err)
        return err;
+#ifndef NO_FILE_CCACHE
     err = k5_mutex_finish_init(&krb5int_cc_file_mutex);
     if (err)
        return err;
+#endif
 #ifdef USE_KEYRING_CCACHE
     err = k5_mutex_finish_init(&krb5int_krcc_mutex);
     if (err)
@@ -114,7 +115,9 @@ krb5int_cc_finalize(void)
 {
     struct krb5_cc_typelist *t, *t_next;
     k5_mutex_destroy(&cc_typelist_lock);
+#ifndef NO_FILE_CCACHE
     k5_mutex_destroy(&krb5int_cc_file_mutex);
+#endif
     k5_mutex_destroy(&krb5int_mcc_mutex);
 #ifdef USE_KEYRING_CCACHE
     k5_mutex_destroy(&krb5int_krcc_mutex);
index cdeab0674c9b06b4dad457ca496ddffc7a71491e..949758bdf87ee21efb82fd2cdc48c680728198c5 100644 (file)
 
 const krb5_cc_ops *krb5_cc_dfl_ops = &krb5_cc_stdcc_ops;
 
+#elif defined(NO_FILE_CCACHE)
+
+/* Note that this version isn't likely to work very well for multiple
+   processes.  It's mostly a placeholder so we can experiment with
+   building the NO_FILE_CCACHE code on UNIX.  */
+
+extern const krb5_cc_ops krb5_mcc_ops;
+const krb5_cc_ops *krb5_cc_dfl_ops = &krb5_mcc_ops;
+
 #else
 
 #include "fcc.h"