2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-28 21:17:54 +00:00

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.
This commit is contained in:
Mark Andrews 1999-12-23 05:05:04 +00:00
parent 3ddd814a97
commit 202e42a230

View File

@ -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);
}
}