2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Improve reporting for mutex errors

Replace all uses of RUNTIME_CHECK() in lib/isc/include/isc/mutex.h with
ERRNO_CHECK(), in order to improve error reporting for any mutex-related
run-time failures (by augmenting error messages with file/line/caller
information and the error string corresponding to errno).
This commit is contained in:
Michał Kępień
2022-07-13 13:19:32 +02:00
parent 34a804d956
commit f352a834a7

View File

@@ -32,7 +32,7 @@ typedef pthread_mutex_t *isc_mutex_t;
#define isc_mutex_init(mp) \
{ \
*mp = malloc(sizeof(**mp)); \
isc__mutex_init((*mp)); \
isc__mutex_init(*mp); \
}
#define isc_mutex_lock(mp) isc__mutex_lock(*mp)
#define isc_mutex_unlock(mp) isc__mutex_unlock(*mp)
@@ -47,7 +47,7 @@ typedef pthread_mutex_t *isc_mutex_t;
typedef pthread_mutex_t isc_mutex_t;
#define isc_mutex_init(mp) isc__mutex_init((mp))
#define isc_mutex_init(mp) isc__mutex_init(mp)
#define isc_mutex_lock(mp) isc__mutex_lock(mp)
#define isc_mutex_unlock(mp) isc__mutex_unlock(mp)
#define isc_mutex_trylock(mp) isc__mutex_trylock(mp)
@@ -63,13 +63,25 @@ extern pthread_mutexattr_t isc__mutex_init_attr;
ERRNO_CHECK(pthread_mutex_init, _ret); \
}
#define isc__mutex_lock(mp) RUNTIME_CHECK(pthread_mutex_lock((mp)) == 0)
#define isc__mutex_lock(mp) \
{ \
int _ret = pthread_mutex_lock(mp); \
ERRNO_CHECK(pthread_mutex_lock, _ret); \
}
#define isc__mutex_unlock(mp) RUNTIME_CHECK(pthread_mutex_unlock((mp)) == 0)
#define isc__mutex_unlock(mp) \
{ \
int _ret = pthread_mutex_unlock(mp); \
ERRNO_CHECK(pthread_mutex_unlock, _ret); \
}
#define isc__mutex_trylock(mp) \
((pthread_mutex_trylock((mp)) == 0) ? ISC_R_SUCCESS : ISC_R_LOCKBUSY)
((pthread_mutex_trylock(mp) == 0) ? ISC_R_SUCCESS : ISC_R_LOCKBUSY)
#define isc__mutex_destroy(mp) RUNTIME_CHECK(pthread_mutex_destroy((mp)) == 0)
#define isc__mutex_destroy(mp) \
{ \
int _ret = pthread_mutex_destroy(mp); \
ERRNO_CHECK(pthread_mutex_destroy, _ret); \
}
ISC_LANG_ENDDECLS