aboutsummaryrefslogtreecommitdiff
path: root/src/lib/krb5/rcache
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2013-05-10 14:01:48 -0400
committerGreg Hudson <ghudson@mit.edu>2013-05-14 13:31:41 -0400
commit6350fd0c909d84c00200885e722cc902049ada05 (patch)
treea880eae4b875d2b94747048a7092f619c79d33c2 /src/lib/krb5/rcache
parent1799f7b5d9cf4390148248d603d99a3695ddfafe (diff)
downloadkrb5-6350fd0c909d84c00200885e722cc902049ada05.zip
krb5-6350fd0c909d84c00200885e722cc902049ada05.tar.gz
krb5-6350fd0c909d84c00200885e722cc902049ada05.tar.bz2
Assume mutex locking cannot fail
Locking and unlocking a non-recursive mutex is a simple memory operation and should not fail on any reasonable platform with correct usage. A pthread mutex can return EDEADLK on lock or EPERM on unlock, or EINVAL if the mutex is uninitialized, but all of these conditions would reflect serious bugs in the calling code. Change the k5_mutex_lock and k5_mutex_unlock wrappers to return void and adjust all call sites. Propagate this change through k5_cc_mutex_lock and k5_cc_mutex_unlock as well.
Diffstat (limited to 'src/lib/krb5/rcache')
-rw-r--r--src/lib/krb5/rcache/rc_base.c10
-rw-r--r--src/lib/krb5/rcache/rc_dfl.c32
2 files changed, 12 insertions, 30 deletions
diff --git a/src/lib/krb5/rcache/rc_base.c b/src/lib/krb5/rcache/rc_base.c
index 5097271..2fc96c5 100644
--- a/src/lib/krb5/rcache/rc_base.c
+++ b/src/lib/krb5/rcache/rc_base.c
@@ -44,10 +44,8 @@ krb5_error_code
krb5_rc_register_type(krb5_context context, const krb5_rc_ops *ops)
{
struct krb5_rc_typelist *t;
- krb5_error_code err;
- err = k5_mutex_lock(&rc_typelist_lock);
- if (err)
- return err;
+
+ k5_mutex_lock(&rc_typelist_lock);
for (t = typehead;t && strcmp(t->ops->type,ops->type);t = t->next)
;
if (t) {
@@ -76,9 +74,7 @@ krb5_rc_resolve_type(krb5_context context, krb5_rcache *idptr, char *type)
*idptr = NULL;
/* Find the named type in the list. */
- err = k5_mutex_lock(&rc_typelist_lock);
- if (err)
- return err;
+ k5_mutex_lock(&rc_typelist_lock);
for (t = typehead; t && strcmp(t->ops->type, type); t = t->next)
;
k5_mutex_unlock(&rc_typelist_lock);
diff --git a/src/lib/krb5/rcache/rc_dfl.c b/src/lib/krb5/rcache/rc_dfl.c
index 12e2a5d..70d98c1 100644
--- a/src/lib/krb5/rcache/rc_dfl.c
+++ b/src/lib/krb5/rcache/rc_dfl.c
@@ -201,12 +201,9 @@ krb5_error_code KRB5_CALLCONV
krb5_rc_dfl_get_span(krb5_context context, krb5_rcache id,
krb5_deltat *lifespan)
{
- krb5_error_code err;
struct dfl_data *t;
- err = k5_mutex_lock(&id->lock);
- if (err)
- return err;
+ k5_mutex_lock(&id->lock);
t = (struct dfl_data *) id->data;
*lifespan = t->lifespan;
k5_mutex_unlock(&id->lock);
@@ -239,9 +236,7 @@ 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;
+ k5_mutex_lock(&id->lock);
retval = krb5_rc_dfl_init_locked(context, id, lifespan);
k5_mutex_unlock(&id->lock);
return retval;
@@ -276,10 +271,7 @@ krb5_rc_dfl_close_no_free(krb5_context context, krb5_rcache id)
krb5_error_code KRB5_CALLCONV
krb5_rc_dfl_close(krb5_context context, krb5_rcache id)
{
- krb5_error_code retval;
- retval = k5_mutex_lock(&id->lock);
- if (retval)
- return retval;
+ k5_mutex_lock(&id->lock);
krb5_rc_dfl_close_no_free(context, id);
k5_mutex_unlock(&id->lock);
k5_mutex_destroy(&id->lock);
@@ -624,9 +616,8 @@ krb5_error_code KRB5_CALLCONV
krb5_rc_dfl_recover(krb5_context context, krb5_rcache id)
{
krb5_error_code ret;
- ret = k5_mutex_lock(&id->lock);
- if (ret)
- return ret;
+
+ k5_mutex_lock(&id->lock);
ret = krb5_rc_dfl_recover_locked(context, id);
k5_mutex_unlock(&id->lock);
return ret;
@@ -638,9 +629,7 @@ krb5_rc_dfl_recover_or_init(krb5_context context, krb5_rcache id,
{
krb5_error_code retval;
- retval = k5_mutex_lock(&id->lock);
- if (retval)
- return retval;
+ k5_mutex_lock(&id->lock);
retval = krb5_rc_dfl_recover_locked(context, id);
if (retval)
retval = krb5_rc_dfl_init_locked(context, id, lifespan);
@@ -727,9 +716,7 @@ krb5_rc_dfl_store(krb5_context context, krb5_rcache id, krb5_donot_replay *rep)
if (ret)
return ret;
- ret = k5_mutex_lock(&id->lock);
- if (ret)
- return ret;
+ k5_mutex_lock(&id->lock);
switch(rc_store(context, id, rep, now, FALSE)) {
case CMP_MALLOC:
@@ -859,9 +846,8 @@ krb5_error_code KRB5_CALLCONV
krb5_rc_dfl_expunge(krb5_context context, krb5_rcache id)
{
krb5_error_code ret;
- ret = k5_mutex_lock(&id->lock);
- if (ret)
- return ret;
+
+ k5_mutex_lock(&id->lock);
ret = krb5_rc_dfl_expunge_locked(context, id);
k5_mutex_unlock(&id->lock);
return ret;