mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
Improve reporting for pthread_once errors
Replace all uses of RUNTIME_CHECK() in lib/isc/include/isc/once.h with PTHEADS_RUNTIME_CHECK(), in order to improve error reporting for any once-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:
committed by
Ondřej Surý
parent
2ac48846f4
commit
cedfc97974
@@ -3726,7 +3726,7 @@ named_statschannels_configure(named_server_t *server, const cfg_obj_t *config,
|
|||||||
const cfg_listelt_t *element, *element2;
|
const cfg_listelt_t *element, *element2;
|
||||||
char socktext[ISC_SOCKADDR_FORMATSIZE];
|
char socktext[ISC_SOCKADDR_FORMATSIZE];
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_once_do(&once, init_desc) == ISC_R_SUCCESS);
|
isc_once_do(&once, init_desc);
|
||||||
|
|
||||||
ISC_LIST_INIT(new_listeners);
|
ISC_LIST_INIT(new_listeners);
|
||||||
|
|
||||||
@@ -3883,7 +3883,7 @@ named_stats_dump(named_server_t *server, FILE *fp) {
|
|||||||
uint64_t sockstat_values[isc_sockstatscounter_max];
|
uint64_t sockstat_values[isc_sockstatscounter_max];
|
||||||
uint64_t gluecachestats_values[dns_gluecachestatscounter_max];
|
uint64_t gluecachestats_values[dns_gluecachestatscounter_max];
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_once_do(&once, init_desc) == ISC_R_SUCCESS);
|
isc_once_do(&once, init_desc);
|
||||||
|
|
||||||
/* Set common fields */
|
/* Set common fields */
|
||||||
dumparg.type = isc_statsformat_file;
|
dumparg.type = isc_statsformat_file;
|
||||||
|
@@ -616,8 +616,7 @@ dns_acl_isinsecure(const dns_acl_t *a) {
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
bool insecure;
|
bool insecure;
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_once_do(&insecure_prefix_once, initialize_action) ==
|
isc_once_do(&insecure_prefix_once, initialize_action);
|
||||||
ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Walk radix tree to find out if there are any non-negated,
|
* Walk radix tree to find out if there are any non-negated,
|
||||||
|
@@ -106,7 +106,7 @@ dns_db_create(isc_mem_t *mctx, const char *db_type, const dns_name_t *origin,
|
|||||||
char *argv[], dns_db_t **dbp) {
|
char *argv[], dns_db_t **dbp) {
|
||||||
dns_dbimplementation_t *impinfo;
|
dns_dbimplementation_t *impinfo;
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
|
isc_once_do(&once, initialize);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new database using implementation 'db_type'.
|
* Create a new database using implementation 'db_type'.
|
||||||
@@ -841,7 +841,7 @@ dns_db_register(const char *name, dns_dbcreatefunc_t create, void *driverarg,
|
|||||||
REQUIRE(name != NULL);
|
REQUIRE(name != NULL);
|
||||||
REQUIRE(dbimp != NULL && *dbimp == NULL);
|
REQUIRE(dbimp != NULL && *dbimp == NULL);
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
|
isc_once_do(&once, initialize);
|
||||||
|
|
||||||
RWLOCK(&implock, isc_rwlocktype_write);
|
RWLOCK(&implock, isc_rwlocktype_write);
|
||||||
imp = impfind(name);
|
imp = impfind(name);
|
||||||
@@ -871,7 +871,7 @@ dns_db_unregister(dns_dbimplementation_t **dbimp) {
|
|||||||
|
|
||||||
REQUIRE(dbimp != NULL && *dbimp != NULL);
|
REQUIRE(dbimp != NULL && *dbimp != NULL);
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
|
isc_once_do(&once, initialize);
|
||||||
|
|
||||||
imp = *dbimp;
|
imp = *dbimp;
|
||||||
*dbimp = NULL;
|
*dbimp = NULL;
|
||||||
|
@@ -166,7 +166,7 @@ dns_dlzcreate(isc_mem_t *mctx, const char *dlzname, const char *drivername,
|
|||||||
* initialize the dlz_implementations list, this is guaranteed
|
* initialize the dlz_implementations list, this is guaranteed
|
||||||
* to only really happen once.
|
* to only really happen once.
|
||||||
*/
|
*/
|
||||||
RUNTIME_CHECK(isc_once_do(&once, dlz_initialize) == ISC_R_SUCCESS);
|
isc_once_do(&once, dlz_initialize);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Performs checks to make sure data is as we expect it to be.
|
* Performs checks to make sure data is as we expect it to be.
|
||||||
@@ -296,7 +296,7 @@ dns_dlzregister(const char *drivername, const dns_dlzmethods_t *methods,
|
|||||||
* initialize the dlz_implementations list, this is guaranteed
|
* initialize the dlz_implementations list, this is guaranteed
|
||||||
* to only really happen once.
|
* to only really happen once.
|
||||||
*/
|
*/
|
||||||
RUNTIME_CHECK(isc_once_do(&once, dlz_initialize) == ISC_R_SUCCESS);
|
isc_once_do(&once, dlz_initialize);
|
||||||
|
|
||||||
/* lock the dlz_implementations list so we can modify it. */
|
/* lock the dlz_implementations list so we can modify it. */
|
||||||
RWLOCK(&dlz_implock, isc_rwlocktype_write);
|
RWLOCK(&dlz_implock, isc_rwlocktype_write);
|
||||||
@@ -377,7 +377,7 @@ dns_dlzunregister(dns_dlzimplementation_t **dlzimp) {
|
|||||||
* initialize the dlz_implementations list, this is guaranteed
|
* initialize the dlz_implementations list, this is guaranteed
|
||||||
* to only really happen once.
|
* to only really happen once.
|
||||||
*/
|
*/
|
||||||
RUNTIME_CHECK(isc_once_do(&once, dlz_initialize) == ISC_R_SUCCESS);
|
isc_once_do(&once, dlz_initialize);
|
||||||
|
|
||||||
dlz_imp = *dlzimp;
|
dlz_imp = *dlzimp;
|
||||||
|
|
||||||
|
@@ -212,7 +212,7 @@ dns_dyndb_load(const char *libname, const char *name, const char *parameters,
|
|||||||
REQUIRE(DNS_DYNDBCTX_VALID(dctx));
|
REQUIRE(DNS_DYNDBCTX_VALID(dctx));
|
||||||
REQUIRE(name != NULL);
|
REQUIRE(name != NULL);
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_once_do(&once, dyndb_initialize) == ISC_R_SUCCESS);
|
isc_once_do(&once, dyndb_initialize);
|
||||||
|
|
||||||
LOCK(&dyndb_lock);
|
LOCK(&dyndb_lock);
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ dns_dyndb_cleanup(bool exiting) {
|
|||||||
dyndb_implementation_t *elem;
|
dyndb_implementation_t *elem;
|
||||||
dyndb_implementation_t *prev;
|
dyndb_implementation_t *prev;
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_once_do(&once, dyndb_initialize) == ISC_R_SUCCESS);
|
isc_once_do(&once, dyndb_initialize);
|
||||||
|
|
||||||
LOCK(&dyndb_lock);
|
LOCK(&dyndb_lock);
|
||||||
elem = TAIL(dyndb_implementations);
|
elem = TAIL(dyndb_implementations);
|
||||||
|
@@ -82,7 +82,7 @@ fromtext_in_wks(ARGS_FROMTEXT) {
|
|||||||
UNUSED(rdclass);
|
UNUSED(rdclass);
|
||||||
UNUSED(callbacks);
|
UNUSED(callbacks);
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_once_do(&once, init_lock) == ISC_R_SUCCESS);
|
isc_once_do(&once, init_lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IPv4 dotted quad.
|
* IPv4 dotted quad.
|
||||||
|
@@ -52,9 +52,7 @@ isc_hash_initialize(void) {
|
|||||||
const void *
|
const void *
|
||||||
isc_hash_get_initializer(void) {
|
isc_hash_get_initializer(void) {
|
||||||
if (!hash_initialized) {
|
if (!hash_initialized) {
|
||||||
RUNTIME_CHECK(
|
isc_once_do(&isc_hash_once, isc_hash_initialize);
|
||||||
isc_once_do(&isc_hash_once, isc_hash_initialize) ==
|
|
||||||
ISC_R_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (isc_hash_key);
|
return (isc_hash_key);
|
||||||
@@ -69,9 +67,7 @@ isc_hash_set_initializer(const void *initializer) {
|
|||||||
* isc_hash_set_initializer() is called.
|
* isc_hash_set_initializer() is called.
|
||||||
*/
|
*/
|
||||||
if (!hash_initialized) {
|
if (!hash_initialized) {
|
||||||
RUNTIME_CHECK(
|
isc_once_do(&isc_hash_once, isc_hash_initialize);
|
||||||
isc_once_do(&isc_hash_once, isc_hash_initialize) ==
|
|
||||||
ISC_R_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(isc_hash_key, initializer, sizeof(isc_hash_key));
|
memmove(isc_hash_key, initializer, sizeof(isc_hash_key));
|
||||||
@@ -83,8 +79,7 @@ isc_hash64(const void *data, const size_t length, const bool case_sensitive) {
|
|||||||
|
|
||||||
REQUIRE(length == 0 || data != NULL);
|
REQUIRE(length == 0 || data != NULL);
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_once_do(&isc_hash_once, isc_hash_initialize) ==
|
isc_once_do(&isc_hash_once, isc_hash_initialize);
|
||||||
ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
isc_siphash24(isc_hash_key, data, length, case_sensitive,
|
isc_siphash24(isc_hash_key, data, length, case_sensitive,
|
||||||
(uint8_t *)&hval);
|
(uint8_t *)&hval);
|
||||||
@@ -98,8 +93,7 @@ isc_hash32(const void *data, const size_t length, const bool case_sensitive) {
|
|||||||
|
|
||||||
REQUIRE(length == 0 || data != NULL);
|
REQUIRE(length == 0 || data != NULL);
|
||||||
|
|
||||||
RUNTIME_CHECK(isc_once_do(&isc_hash_once, isc_hash_initialize) ==
|
isc_once_do(&isc_hash_once, isc_hash_initialize);
|
||||||
ISC_R_SUCCESS);
|
|
||||||
|
|
||||||
isc_halfsiphash24(isc_hash_key, data, length, case_sensitive,
|
isc_halfsiphash24(isc_hash_key, data, length, case_sensitive,
|
||||||
(uint8_t *)&hval);
|
(uint8_t *)&hval);
|
||||||
|
@@ -23,7 +23,8 @@ typedef pthread_once_t isc_once_t;
|
|||||||
|
|
||||||
#define ISC_ONCE_INIT PTHREAD_ONCE_INIT
|
#define ISC_ONCE_INIT PTHREAD_ONCE_INIT
|
||||||
|
|
||||||
/* XXX We could do fancier error handling... */
|
#define isc_once_do(op, f) \
|
||||||
|
{ \
|
||||||
#define isc_once_do(op, f) \
|
int _ret = pthread_once((op), (f)); \
|
||||||
((pthread_once((op), (f)) == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
PTHREADS_RUNTIME_CHECK(pthread_once, _ret); \
|
||||||
|
}
|
||||||
|
@@ -451,7 +451,7 @@ mem_initialize(void) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
isc__mem_initialize(void) {
|
isc__mem_initialize(void) {
|
||||||
RUNTIME_CHECK(isc_once_do(&init_once, mem_initialize) == ISC_R_SUCCESS);
|
isc_once_do(&init_once, mem_initialize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -463,7 +463,7 @@ mem_shutdown(void) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
isc__mem_shutdown(void) {
|
isc__mem_shutdown(void) {
|
||||||
RUNTIME_CHECK(isc_once_do(&shut_once, mem_shutdown) == ISC_R_SUCCESS);
|
isc_once_do(&shut_once, mem_shutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -43,8 +43,7 @@ mutex_initialize(void) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
isc__mutex_initialize(void) {
|
isc__mutex_initialize(void) {
|
||||||
RUNTIME_CHECK(isc_once_do(&init_once, mutex_initialize) ==
|
isc_once_do(&init_once, mutex_initialize);
|
||||||
ISC_R_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -198,7 +198,7 @@ initialize_action(void) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
initialize(void) {
|
initialize(void) {
|
||||||
RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
|
isc_once_do(&once, initialize_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
@@ -281,8 +281,7 @@ close:
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
initialize_ipv6only(void) {
|
initialize_ipv6only(void) {
|
||||||
RUNTIME_CHECK(isc_once_do(&once_ipv6only, try_ipv6only) ==
|
isc_once_do(&once_ipv6only, try_ipv6only);
|
||||||
ISC_R_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __notyet__
|
#ifdef __notyet__
|
||||||
@@ -329,8 +328,7 @@ close:
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
initialize_ipv6pktinfo(void) {
|
initialize_ipv6pktinfo(void) {
|
||||||
RUNTIME_CHECK(isc_once_do(&once_ipv6pktinfo, try_ipv6pktinfo) ==
|
isc_once_do(&once_ipv6pktinfo, try_ipv6pktinfo);
|
||||||
ISC_R_SUCCESS);
|
|
||||||
}
|
}
|
||||||
#endif /* ifdef __notyet__ */
|
#endif /* ifdef __notyet__ */
|
||||||
|
|
||||||
@@ -696,7 +694,7 @@ try_dscp(void) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
initialize_dscp(void) {
|
initialize_dscp(void) {
|
||||||
RUNTIME_CHECK(isc_once_do(&once_dscp, try_dscp) == ISC_R_SUCCESS);
|
isc_once_do(&once_dscp, try_dscp);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
|
Reference in New Issue
Block a user