isc_mutex_t lock; /*%< locks all below */
isc_socktype_t socktype;
atomic_uint_fast32_t state;
+ atomic_bool tcpreading;
isc_refcount_t references;
unsigned int shutdown_out : 1;
REQUIRE(VALID_DISPATCH(disp));
+ atomic_store(&disp->tcpreading, false);
+
qid = disp->mgr->qid;
ISC_LIST_INIT(resps);
break;
case isc_socktype_tcp:
- dns_dispatch_attach(disp, &(dns_dispatch_t *){ NULL });
- if (timeout > 0) {
- isc_nmhandle_settimeout(disp->handle, timeout);
+ if (atomic_compare_exchange_strong(&disp->tcpreading,
+ &(bool){ false }, true)) {
+ dns_dispatch_attach(disp, &(dns_dispatch_t *){ NULL });
+ if (timeout > 0) {
+ isc_nmhandle_settimeout(disp->handle, timeout);
+ }
+ isc_nm_read(disp->handle, tcp_recv, disp);
}
- isc_nm_read(disp->handle, tcp_recv, disp);
break;
default: