* rc-int.h (struct _krb5_rc_ops): Add new member, recover_or_init.
authorKen Raeburn <raeburn@mit.edu>
Wed, 4 Aug 2004 06:58:17 +0000 (06:58 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 4 Aug 2004 06:58:17 +0000 (06:58 +0000)
* rc_dfl.c (krb5_rc_dfl_init_locked): New function, with most of the content of
old krb5_rc_dfl_init.
(krb5_rc_dfl_init): Call it.
(krb5_rc_dfl_recover_or_init): New function.
* rc_dfl.h (krb5_rc_dfl_recover_or_init): Declare.
* rcdef.c (krb5_rc_dfl_ops): Initialize new field.
* rc_none.c (krb5_rc_none_recover_or_init): New macro.
(krb5_rc_none_ops): Initialize new field.
* rcfns.c (krb5_rc_recover_or_initialize): New function.

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

src/lib/krb5/rcache/ChangeLog
src/lib/krb5/rcache/rc-int.h
src/lib/krb5/rcache/rc_dfl.c
src/lib/krb5/rcache/rc_dfl.h
src/lib/krb5/rcache/rc_none.c
src/lib/krb5/rcache/rcdef.c
src/lib/krb5/rcache/rcfns.c

index bf5c2f7b56b56d12ac8b80f866000c97f928d633..24b04b015523d38835720161af8fdee1f6f6e938 100644 (file)
@@ -1,3 +1,17 @@
+2004-08-03  Ken Raeburn  <raeburn@mit.edu>
+
+       * rc-int.h (struct _krb5_rc_ops): Add new member,
+       recover_or_init.
+       * rc_dfl.c (krb5_rc_dfl_init_locked): New function, with most of
+       the content of old krb5_rc_dfl_init.
+       (krb5_rc_dfl_init): Call it.
+       (krb5_rc_dfl_recover_or_init): New function.
+       * rc_dfl.h (krb5_rc_dfl_recover_or_init): Declare.
+       * rcdef.c (krb5_rc_dfl_ops): Initialize new field.
+       * rc_none.c (krb5_rc_none_recover_or_init): New macro.
+       (krb5_rc_none_ops): Initialize new field.
+       * rcfns.c (krb5_rc_recover_or_initialize): New function.
+
 2004-07-30  Ken Raeburn  <raeburn@mit.edu>
 
        * rc_none.c: New file.
index 239f0c0a73713771dcf42cc47cd1e461cf35b39d..2f09d239a60341a920e4edf632c22755e3d9152e 100644 (file)
@@ -49,6 +49,8 @@ struct _krb5_rc_ops {
        (krb5_context, krb5_rcache,krb5_deltat); /* create */
     krb5_error_code (KRB5_CALLCONV *recover)
        (krb5_context, krb5_rcache); /* open */
+    krb5_error_code (KRB5_CALLCONV *recover_or_init)
+       (krb5_context, krb5_rcache,krb5_deltat);
     krb5_error_code (KRB5_CALLCONV *destroy)
        (krb5_context, krb5_rcache);
     krb5_error_code (KRB5_CALLCONV *close)
index c4f845178f0ee1c3e36b25c6ef75081fa71600f7..586716a3daa3e5fdef489ba8d88c31ceab8325a8 100644 (file)
@@ -192,32 +192,39 @@ krb5_rc_dfl_get_span(krb5_context context, krb5_rcache id,
 }
 
 krb5_error_code KRB5_CALLCONV
-krb5_rc_dfl_init(krb5_context context, krb5_rcache id, krb5_deltat lifespan)
+krb5_rc_dfl_init_locked(krb5_context context, krb5_rcache id, krb5_deltat lifespan)
 {
     struct dfl_data *t = (struct dfl_data *)id->data;
     krb5_error_code retval;
 
-    retval = k5_mutex_lock(&id->lock);
-    if (retval)
-       return retval;
     t->lifespan = lifespan ? lifespan : context->clockskew;
     /* default to clockskew from the context */
 #ifndef NOIOSTUFF
     if ((retval = krb5_rc_io_creat(context, &t->d, &t->name))) {
-       k5_mutex_unlock(&id->lock);
        return retval;
     }
     if ((krb5_rc_io_write(context, &t->d,
                          (krb5_pointer) &t->lifespan, sizeof(t->lifespan))
         || krb5_rc_io_sync(context, &t->d))) {
-       k5_mutex_unlock(&id->lock);
        return KRB5_RC_IO;
     }
 #endif
-    k5_mutex_unlock(&id->lock);
     return 0;
 }
 
+krb5_error_code KRB5_CALLCONV
+krb5_rc_dfl_init(krb5_context context, krb5_rcache id, krb5_deltat lifespan)
+{
+    krb5_error_code retval;
+
+    retval = k5_mutex_lock(&id->lock);
+    if (retval)
+       return retval;
+    retval = krb5_rc_dfl_init_locked(context, id, lifespan);
+    k5_mutex_unlock(&id->lock);
+    return retval;
+}
+
 /* Called with the mutex already locked.  */
 krb5_error_code
 krb5_rc_dfl_close_no_free(krb5_context context, krb5_rcache id)
@@ -503,6 +510,23 @@ krb5_rc_dfl_recover(krb5_context context, krb5_rcache id)
     return ret;
 }
 
+krb5_error_code KRB5_CALLCONV
+krb5_rc_dfl_recover_or_init(krb5_context context, krb5_rcache id,
+                           krb5_deltat lifespan)
+{
+    struct dfl_data *t = (struct dfl_data *)id->data;
+    krb5_error_code retval;
+
+    retval = k5_mutex_lock(&id->lock);
+    if (retval)
+       return retval;
+    retval = krb5_rc_dfl_recover_locked(context, id);
+    if (retval)
+       retval = krb5_rc_dfl_init_locked(context, id, lifespan);
+    k5_mutex_unlock(&id->lock);
+    return retval;
+}
+
 static krb5_error_code
 krb5_rc_io_store(krb5_context context, struct dfl_data *t,
                 krb5_donot_replay *rep)
index e50ed753bbf8d400c909f0a5a36fff89f4c50882..d5fdd1a69fd77807688d34eb076eb1d681c2d393 100644 (file)
@@ -20,6 +20,8 @@ krb5_error_code KRB5_CALLCONV krb5_rc_dfl_init
 krb5_error_code KRB5_CALLCONV krb5_rc_dfl_recover 
        (krb5_context,
                   krb5_rcache); 
+krb5_error_code KRB5_CALLCONV krb5_rc_dfl_recover_or_init
+       (krb5_context, krb5_rcache, krb5_deltat);
 krb5_error_code KRB5_CALLCONV krb5_rc_dfl_destroy 
        (krb5_context,
                   krb5_rcache);
index 3ad45247b07ea6c1967ea8f8d923b5097cf1ad23..a306f86fe7fbfb7a84ff613262078c115bbb7e35 100644 (file)
@@ -35,6 +35,7 @@ krb5_rc_none_init(krb5_context ctx, krb5_rcache rc, krb5_deltat d)
 {
     return 0;
 }
+#define krb5_rc_none_recover_or_init krb5_rc_none_init
 
 static krb5_error_code KRB5_CALLCONV
 krb5_rc_none_noargs(krb5_context ctx, krb5_rcache rc)
@@ -76,6 +77,7 @@ const krb5_rc_ops krb5_rc_none_ops = {
     "none",
     krb5_rc_none_init,
     krb5_rc_none_recover,
+    krb5_rc_none_recover_or_init,
     krb5_rc_none_destroy,
     krb5_rc_none_close,
     krb5_rc_none_store,
index 73b2eb968094df99754dbafddf3c361536d27034..0aa334fa85df73d60472503d5f69e3ff5096d2eb 100644 (file)
@@ -37,6 +37,7 @@ const krb5_rc_ops krb5_rc_dfl_ops =
   "dfl",
   krb5_rc_dfl_init,
   krb5_rc_dfl_recover,
+  krb5_rc_dfl_recover_or_init,
   krb5_rc_dfl_destroy,
   krb5_rc_dfl_close,
   krb5_rc_dfl_store,
index d37b4f6ec68def5a093a5305cbd0dcda57688da1..bcbcaf4be915e3e4cfd896504f60314bc263be5c 100644 (file)
@@ -37,6 +37,13 @@ krb5_rc_initialize (krb5_context context, krb5_rcache id, krb5_deltat span)
     return krb5_x(id->ops->init,(context, id, span));
 }
 
+krb5_error_code KRB5_CALLCONV
+krb5_rc_recover_or_initialize (krb5_context context, krb5_rcache id,
+                              krb5_deltat span)
+{
+    return krb5_x(id->ops->recover_or_init,(context, id, span));
+}
+
 krb5_error_code KRB5_CALLCONV
 krb5_rc_recover (krb5_context context, krb5_rcache id)
 {