summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2006-01-25 08:05:24 +0000
committerKen Raeburn <raeburn@mit.edu>2006-01-25 08:05:24 +0000
commit210bd523f6351fa35d510f08ff5044e4c27fe363 (patch)
treee79d0f23f9970bec1c26638f5516dfd60081e9ef /src/lib
parent724f3548131de9bb4c77f054262a854b2746c0e6 (diff)
downloadkrb5-210bd523f6351fa35d510f08ff5044e4c27fe363.tar.gz
krb5-210bd523f6351fa35d510f08ff5044e4c27fe363.tar.xz
krb5-210bd523f6351fa35d510f08ff5044e4c27fe363.zip
Remove the thread-safety flag from the kdb plugin interface. Instead,
have the kdb code assume the plugin is thread safe, and implement some quick and dirty wrapper functions in the db2 plugin to make it use a local mutex. There's still some mutex code in the kdb library that should be reviewed, and simplified or removed. ticket: 3416 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17611 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/kdb/ChangeLog9
-rw-r--r--src/lib/kdb/kdb5.c20
-rw-r--r--src/lib/kdb/kdb5.h4
3 files changed, 11 insertions, 22 deletions
diff --git a/src/lib/kdb/ChangeLog b/src/lib/kdb/ChangeLog
index ae159d434..b6677ffee 100644
--- a/src/lib/kdb/ChangeLog
+++ b/src/lib/kdb/ChangeLog
@@ -1,3 +1,12 @@
+2006-01-25 Ken Raeburn <raeburn@mit.edu>
+
+ * kdb5.h (struct _db_library): Delete unlocked and lock_holder
+ fields.
+ (struct _kdb_vftabl): Delete is_thread_safe field.
+ * kdb5.c (kdb_init_lib_lock, kdb_destroy_lib_lock,
+ kdb_lock_lib_lock, kdb_unlock_lib_lock): Delete references.
+ Assume the plugin is always thread-safe.
+
2005-12-02 Ken Raeburn <raeburn@mit.edu>
* kdb5.c (kdb_load_library): Make dbpath_names static, to keep
diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c
index 91f4f8ee3..156ebb65a 100644
--- a/src/lib/kdb/kdb5.c
+++ b/src/lib/kdb/kdb5.c
@@ -84,11 +84,10 @@ kdb_init_lib_lock(db_library lib)
return retval;
}
- lib->lock_holder = pthread_self();
lib->excl = 0;
lib->recursive_cnt = 0;
- return pthread_cond_init(&lib->unlocked, NULL);
+ return 0;
}
static int
@@ -99,7 +98,7 @@ kdb_destroy_lib_lock(db_library lib)
return retval;
}
- return pthread_cond_destroy(&lib->unlocked);
+ return 0;
}
static int
@@ -108,20 +107,10 @@ kdb_lock_lib_lock(db_library lib, krb5_boolean exclusive)
/* Since, handle locked by one thread should not allow another
thread to continue. */
krb5_error_code retval = 0;
- pthread_t myid = pthread_self();
if ((retval = pthread_mutex_lock(&lib->lib_lock)))
return retval;
- while ((exclusive && (lib->excl || lib->recursive_cnt)) ||
- (!pthread_equal(lib->lock_holder, myid)
- && !lib->vftabl.is_thread_safe && lib->recursive_cnt)) {
- /* Exclusive lock held or some one using lock when exclusive
- is requested or library not-re-entrant. */
- if ((retval = pthread_cond_wait(&lib->unlocked, &lib->lib_lock)))
- return retval;
- }
-
/* exclusive lock and recursive_cnt allow a thread to lock even it
already holds a lock */
if (exclusive)
@@ -129,8 +118,6 @@ kdb_lock_lib_lock(db_library lib, krb5_boolean exclusive)
lib->recursive_cnt++;
- lib->lock_holder = myid;
-
return pthread_mutex_unlock(&lib->lib_lock);
}
@@ -146,9 +133,6 @@ kdb_unlock_lib_lock(db_library lib, krb5_boolean exclusive)
if (exclusive)
lib->excl--;
- if ((retval = pthread_cond_broadcast(&lib->unlocked)))
- return retval;
-
return pthread_mutex_unlock(&lib->lib_lock);
}
diff --git a/src/lib/kdb/kdb5.h b/src/lib/kdb/kdb5.h
index 93b594a52..4027849e0 100644
--- a/src/lib/kdb/kdb5.h
+++ b/src/lib/kdb/kdb5.h
@@ -49,8 +49,6 @@ typedef struct _kdb_vftabl{
short int maj_ver;
short int min_ver;
- short int is_thread_safe;
-
krb5_error_code (*init_library)(krb5_set_err_func_t);
krb5_error_code (*fini_library)();
krb5_error_code (*init_module) ( krb5_context kcontext,
@@ -200,9 +198,7 @@ typedef struct _db_library {
int reference_cnt;
#ifdef HAVE_PTHREAD_H
pthread_mutex_t lib_lock;
- pthread_cond_t unlocked; /* To check whether some one has called db_unlock */
int recursive_cnt; /* this is used as lock to help recursive locking */
- pthread_t lock_holder;
int excl;
#endif
void *dl_handle;