Compare commits

...

1 Commits

Author SHA1 Message Date
Evan Hunt
3ba34c4c49 log when initializing mutex and rwlock 2020-03-24 15:27:20 -07:00
3 changed files with 25 additions and 6 deletions

View File

@@ -79,8 +79,11 @@ struct isc_rwlock {
#endif /* USE_PTHREAD_RWLOCK */
isc_result_t
isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
unsigned int write_quota);
isc__rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
unsigned int write_quota, const char *file,
unsigned int line);
#define isc_rwlock_init(l, rq, wq) isc__rwlock_init((l), (rq), (wq),\
__FILE__, __LINE__)
isc_result_t
isc_rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type);

View File

@@ -17,6 +17,7 @@
#include <sys/time.h>
#include <time.h>
#include <isc/log.h>
#include <isc/mutex.h>
#include <isc/once.h>
#include <isc/print.h>
@@ -294,6 +295,11 @@ isc__mutex_init(isc_mutex_t *mp, const char *file, unsigned int line) {
strerror_r(err, strbuf, sizeof(strbuf));
isc_error_fatal(file, line, "pthread_mutex_init failed: %s",
strbuf);
} else {
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
ISC_LOGMODULE_OTHER, ISC_LOG_INFO,
"Initialized mutex %p at %s:%d",
mp, file, line);
}
}
#endif /* if !(ISC_MUTEX_DEBUG && defined(PTHREAD_MUTEX_ERRORCHECK)) && \

View File

@@ -20,6 +20,7 @@
#endif /* if defined(sun) && (defined(__sparc) || defined(__sparc__)) */
#include <isc/atomic.h>
#include <isc/log.h>
#include <isc/magic.h>
#include <isc/platform.h>
#include <isc/print.h>
@@ -32,11 +33,16 @@
#include <pthread.h>
isc_result_t
isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
unsigned int write_quota) {
isc__rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
unsigned int write_quota, const char *file,
unsigned int line) {
UNUSED(read_quota);
UNUSED(write_quota);
REQUIRE(pthread_rwlock_init(&rwl->rwlock, NULL) == 0);
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
ISC_LOGMODULE_OTHER, ISC_LOG_INFO,
"Initialized rwlock %p at %s:%d",
&rwl->rwlock, file, line);
atomic_init(&rwl->downgrade, false);
return (ISC_R_SUCCESS);
}
@@ -190,10 +196,14 @@ print_lock(const char *operation, isc_rwlock_t *rwl, isc_rwlocktype_t type) {
#endif /* ISC_RWLOCK_TRACE */
isc_result_t
isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
unsigned int write_quota) {
isc__rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
unsigned int write_quota, const char *file,
unsigned int line) {
REQUIRE(rwl != NULL);
UNUSED(file);
UNUSED(line);
/*
* In case there's trouble initializing, we zero magic now. If all
* goes well, we'll set it to RWLOCK_MAGIC.