gettimeofday(&conn.d_connectionStartTime, nullptr);
conn.d_nbQueries = 0;
- conn.d_acceptCtx = dsc->accept_ctx;
+ conn.d_acceptCtx = std::atomic_load_explicit(&dsc->accept_ctx, std::memory_order_acquire);
conn.d_desc = descriptor;
sock->on_close.cb = on_socketclose;
{
auto newAcceptContext = std::make_shared<DOHAcceptContext>();
setupAcceptContext(*newAcceptContext, *d_dsc, true);
- d_dsc->accept_ctx = newAcceptContext;
+ std::atomic_store_explicit(&d_dsc->accept_ctx, newAcceptContext, std::memory_order_release);
}
void DOHFrontend::setup()
bool TLSFrontend::setupTLS()
{
#ifdef HAVE_DNS_OVER_TLS
+ std::shared_ptr<TLSCtx> newCtx{nullptr};
/* get the "best" available provider */
if (!d_provider.empty()) {
#ifdef HAVE_GNUTLS
if (d_provider == "gnutls") {
- d_ctx = std::make_shared<GnuTLSIOCtx>(*this);
+ newCtx = std::make_shared<GnuTLSIOCtx>(*this);
+ std::atomic_store_explicit(&d_ctx, newCtx, std::memory_order_release);
return true;
}
#endif /* HAVE_GNUTLS */
#ifdef HAVE_LIBSSL
if (d_provider == "openssl") {
- d_ctx = std::make_shared<OpenSSLTLSIOCtx>(*this);
+ newCtx = std::make_shared<OpenSSLTLSIOCtx>(*this);
+ std::atomic_store_explicit(&d_ctx, newCtx, std::memory_order_release);
return true;
}
#endif /* HAVE_LIBSSL */
}
#ifdef HAVE_LIBSSL
- d_ctx = std::make_shared<OpenSSLTLSIOCtx>(*this);
+ newCtx = std::make_shared<OpenSSLTLSIOCtx>(*this);
#else /* HAVE_LIBSSL */
#ifdef HAVE_GNUTLS
- d_ctx = std::make_shared<GnuTLSIOCtx>(*this);
+ newCtx = std::make_shared<GnuTLSIOCtx>(*this);
#endif /* HAVE_GNUTLS */
#endif /* HAVE_LIBSSL */
+ std::atomic_store_explicit(&d_ctx, newCtx, std::memory_order_release);
#endif /* HAVE_DNS_OVER_TLS */
return true;
}
protected:
std::atomic_flag d_rotatingTicketsKey;
+ std::atomic<time_t> d_ticketsKeyNextRotation{0};
time_t d_ticketsKeyRotationDelay{0};
- time_t d_ticketsKeyNextRotation{0};
};
class TLSFrontend
}
}
- std::shared_ptr<TLSCtx>& getContext()
+ std::shared_ptr<TLSCtx> getContext()
{
- return d_ctx;
+ return std::atomic_load_explicit(&d_ctx, std::memory_order_acquire);
}
void cleanup()