summaryrefslogtreecommitdiffstats
path: root/src/plugins/kdb/ldap
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/plugins/kdb/ldap
parent1799f7b5d9cf4390148248d603d99a3695ddfafe (diff)
downloadkrb5-6350fd0c909d84c00200885e722cc902049ada05.tar.gz
krb5-6350fd0c909d84c00200885e722cc902049ada05.tar.xz
krb5-6350fd0c909d84c00200885e722cc902049ada05.zip
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/plugins/kdb/ldap')
-rw-r--r--src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c4
-rw-r--r--src/plugins/kdb/ldap/libkdb_ldap/ldap_handle.c15
2 files changed, 6 insertions, 13 deletions
diff --git a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c
index 6f5364060..02fbadc42 100644
--- a/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c
+++ b/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c
@@ -162,9 +162,7 @@ krb5_ldap_db_init(krb5_context context, krb5_ldap_context *ldap_context)
ldap_set_option(NULL, LDAP_X_OPT_CONNECT_TIMEOUT, &local_timelimit);
#endif
- st = HNDL_LOCK(ldap_context);
- if (st)
- return st;
+ HNDL_LOCK(ldap_context);
while (ldap_context->server_info_list[cnt] != NULL) {
krb5_ldap_server_info *server_info=NULL;
diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_handle.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_handle.c
index 2261e6322..2188b2d31 100644
--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_handle.c
+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_handle.c
@@ -217,9 +217,7 @@ krb5_ldap_request_handle_from_pool(krb5_ldap_context *ldap_context,
*ldap_server_handle = NULL;
- st = HNDL_LOCK(ldap_context);
- if (st)
- return st;
+ HNDL_LOCK(ldap_context);
if (((*ldap_server_handle)=krb5_get_ldap_handle(ldap_context)) == NULL)
(*ldap_server_handle)=krb5_retry_get_ldap_handle(ldap_context, &st);
HNDL_UNLOCK(ldap_context);
@@ -238,9 +236,7 @@ krb5_ldap_request_next_handle_from_pool(krb5_ldap_context *ldap_context,
{
krb5_error_code st=0;
- st = HNDL_LOCK(ldap_context);
- if (st)
- return st;
+ HNDL_LOCK(ldap_context);
(*ldap_server_handle)->server_info->server_status = OFF;
time(&(*ldap_server_handle)->server_info->downtime);
krb5_put_ldap_handle(*ldap_server_handle);
@@ -261,10 +257,9 @@ krb5_ldap_put_handle_to_pool(krb5_ldap_context *ldap_context,
krb5_ldap_server_handle *ldap_server_handle)
{
if (ldap_server_handle != NULL) {
- if (HNDL_LOCK(ldap_context) == 0) {
- krb5_put_ldap_handle(ldap_server_handle);
- HNDL_UNLOCK(ldap_context);
- }
+ HNDL_LOCK(ldap_context);
+ krb5_put_ldap_handle(ldap_server_handle);
+ HNDL_UNLOCK(ldap_context);
}
return;
}