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

REQUIRE should not have side effects

it's a style violation to have REQUIRE or INSIST contain code that
must run for the server to work. this was being done with some
atomic_compare_exchange calls. these have been cleaned up.  uses
of atomic_compare_exchange in assertions have been replaced with
a new macro atomic_compare_exchange_enforced, which uses RUNTIME_CHECK
to ensure that the exchange was successful.
This commit is contained in:
Evan Hunt
2021-10-21 02:28:48 -07:00
parent 7e49c5e38a
commit a499794984
12 changed files with 80 additions and 55 deletions

View File

@@ -1694,12 +1694,13 @@ startrecv(isc_nmhandle_t *handle, dns_dispatch_t *disp, dns_dispentry_t *resp) {
case isc_socktype_tcp:
REQUIRE(disp != NULL);
LOCK(&disp->lock);
REQUIRE(disp->handle == NULL);
REQUIRE(atomic_compare_exchange_strong(
atomic_compare_exchange_enforced(
&disp->tcpstate,
&(uint_fast32_t){ DNS_DISPATCHSTATE_CONNECTING },
DNS_DISPATCHSTATE_CONNECTED));
DNS_DISPATCHSTATE_CONNECTED);
isc_nmhandle_attach(handle, &disp->handle);
dns_dispatch_attach(disp, &(dns_dispatch_t *){ NULL });