rwlock.c revision 9c3531d72aeaad6c5f01efe6a1c82023e1379e4d
/*
* Copyright (C) 1998-2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
/* $Id: rwlock.c,v 1.16 2000/06/22 21:57:11 tale Exp $ */
#include <config.h>
#ifdef ISC_RWLOCK_TRACE
static void
"%s(%s): %s, %u active, %u granted, "
"%u rwaiting, %u wwaiting\n",
}
#endif
unsigned int write_quota)
{
/*
* In case there's trouble initializing, we zero magic now. If all
* goes well, we'll set it to RWLOCK_MAGIC.
*/
rwl->readers_waiting = 0;
rwl->writers_waiting = 0;
if (read_quota == 0)
read_quota = 4;
if (write_quota == 0)
write_quota = 4;
if (result != ISC_R_SUCCESS) {
"isc_mutex_init() failed: %s",
return (ISC_R_UNEXPECTED);
}
if (result != ISC_R_SUCCESS) {
"isc_condition_init(readable) failed: %s",
return (ISC_R_UNEXPECTED);
}
if (result != ISC_R_SUCCESS) {
"isc_condition_init(writeable) failed: %s",
return (ISC_R_UNEXPECTED);
}
return (ISC_R_SUCCESS);
}
#ifdef ISC_RWLOCK_TRACE
#endif
if (type == isc_rwlocktype_read) {
if (rwl->readers_waiting != 0)
while (!done) {
if (!skip &&
} else {
rwl->readers_waiting++;
rwl->readers_waiting--;
}
}
} else {
if (rwl->writers_waiting != 0)
while (!done) {
} else {
rwl->writers_waiting++;
rwl->writers_waiting--;
}
}
}
#ifdef ISC_RWLOCK_TRACE
#endif
return (ISC_R_SUCCESS);
}
#ifdef ISC_RWLOCK_TRACE
#endif
if (rwl->writers_waiting > 0) {
} else if (rwl->readers_waiting > 0) {
/* Does this case ever happen? */
}
} else {
if (rwl->readers_waiting > 0) {
if (rwl->writers_waiting > 0 &&
} else {
}
} else if (rwl->writers_waiting > 0) {
} else {
}
}
} else {
rwl->writers_waiting == 0) {
if (rwl->readers_waiting > 0)
}
}
#ifdef ISC_RWLOCK_TRACE
#endif
return (ISC_R_SUCCESS);
}
void
rwl->readers_waiting == 0 &&
rwl->writers_waiting == 0);
}