diff options
author | unknown <monty@hundin.mysql.fi> | 2002-06-29 00:16:15 +0300 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2002-06-29 00:16:15 +0300 |
commit | 370016677af391c58c03a0eca198936b3ac5d382 (patch) | |
tree | 4ad1a20d59a1252f985bb184bc8e51fc1988c045 /mysys/thr_rwlock.c | |
parent | 7311cbe7dee5980d921ec43177fd268783eb18e2 (diff) | |
download | mariadb-git-370016677af391c58c03a0eca198936b3ac5d382.tar.gz |
Added support for semaphores in mysys.
(Needed for query cache for systems which doesn't have native semaphores)
mysys/my_getopt.c:
Safety fix.
mysys/my_winsem.c:
Shange all semaphore code to be uniform
mysys/thr_rwlock.c:
cleanup
sql/gen_lex_hash.cc:
Error message if wrong number of arguments.
sql/slave.cc:
R
Diffstat (limited to 'mysys/thr_rwlock.c')
-rw-r--r-- | mysys/thr_rwlock.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/mysys/thr_rwlock.c b/mysys/thr_rwlock.c index 4e2cf3554b7..5f561762a3a 100644 --- a/mysys/thr_rwlock.c +++ b/mysys/thr_rwlock.c @@ -58,7 +58,7 @@ * Mountain View, California 94043 */ -int my_rwlock_init( rw_lock_t *rwp, void *arg __attribute__((unused))) +int my_rwlock_init(rw_lock_t *rwp, void *arg __attribute__((unused))) { pthread_condattr_t cond_attr; @@ -74,7 +74,9 @@ int my_rwlock_init( rw_lock_t *rwp, void *arg __attribute__((unused))) return( 0 ); } -int my_rwlock_destroy( rw_lock_t *rwp ) { + +int my_rwlock_destroy(rw_lock_t *rwp) +{ pthread_mutex_destroy( &rwp->lock ); pthread_cond_destroy( &rwp->readers ); pthread_cond_destroy( &rwp->writers ); @@ -82,11 +84,13 @@ int my_rwlock_destroy( rw_lock_t *rwp ) { return( 0 ); } -int my_rw_rdlock( rw_lock_t *rwp ) { + +int my_rw_rdlock(rw_lock_t *rwp) +{ pthread_mutex_lock(&rwp->lock); /* active or queued writers */ - while ( ( rwp->state < 0 ) || rwp->waiters ) + while (( rwp->state < 0 ) || rwp->waiters) pthread_cond_wait( &rwp->readers, &rwp->lock); rwp->state++; @@ -95,8 +99,8 @@ int my_rw_rdlock( rw_lock_t *rwp ) { return( 0 ); } -int my_rw_wrlock( rw_lock_t *rwp ) { - +int my_rw_wrlock(rw_lock_t *rwp) +{ pthread_mutex_lock(&rwp->lock); rwp->waiters++; /* another writer queued */ @@ -106,10 +110,12 @@ int my_rw_wrlock( rw_lock_t *rwp ) { --rwp->waiters; pthread_mutex_unlock( &rwp->lock ); - return( 0 ); + return(0); } -int my_rw_unlock( rw_lock_t *rwp ) { + +int my_rw_unlock(rw_lock_t *rwp) +{ DBUG_PRINT("rw_unlock", ("state: %d waiters: %d", rwp->state, rwp->waiters)); pthread_mutex_lock(&rwp->lock); @@ -121,7 +127,9 @@ int my_rw_unlock( rw_lock_t *rwp ) { pthread_cond_signal( &rwp->writers ); else pthread_cond_broadcast( &rwp->readers ); - } else { + } + else + { if ( --rwp->state == 0 ) /* no more readers */ pthread_cond_signal( &rwp->writers ); } |