From 202e42a2301bd12183ff46b87c1310df060bede3 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 23 Dec 1999 05:05:04 +0000 Subject: [PATCH] Print lock tracing to stderr. Decrement granted read lock when releasing a read lock if there are no pending write locks. This still allows fair queuing between read and write locks but does not block on aquiring a new read relock if we are below quota of active locks and there are no pending writes. --- lib/isc/rwlock.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/isc/rwlock.c b/lib/isc/rwlock.c index 9075556c22..baa9485b71 100644 --- a/lib/isc/rwlock.c +++ b/lib/isc/rwlock.c @@ -32,14 +32,12 @@ #ifdef ISC_RWLOCK_TRACE static void print_lock(char *operation, isc_rwlock_t *rwl, isc_rwlocktype_t type) { - printf("%s(%s): ", operation, - (type == isc_rwlocktype_read ? "read" : "write")); - printf("%s, %u active, %u granted", - (rwl->type == isc_rwlocktype_read ? "reading" : "writing"), - rwl->active, rwl->granted); - printf(", %u rwaiting, %u wwaiting\n", - rwl->readers_waiting, - rwl->writers_waiting); + fprintf(stderr, + "%s(%s): %s, %u active, %u granted, %u rwaiting, %u wwaiting\n", + operation, (type == isc_rwlocktype_read ? "read" : "write"), + (rwl->type == isc_rwlocktype_read ? "reading" : "writing"), + rwl->active, rwl->granted, rwl->readers_waiting, + rwl->writers_waiting); } #endif @@ -196,11 +194,11 @@ isc_rwlock_unlock(isc_rwlock_t *rwl, isc_rwlocktype_t type) { } } else { if (rwl->type == isc_rwlocktype_read && - rwl->writers_waiting == 0 && - rwl->readers_waiting > 0) { + rwl->writers_waiting == 0) { INSIST(rwl->granted > 0); rwl->granted--; - SIGNAL(&rwl->readable); + if (rwl->readers_waiting > 0) + SIGNAL(&rwl->readable); } }