bool canBeReused() const override;
+ void setHealthCheck(bool h)
+ {
+ d_healthCheckQuery = h;
+ }
+
private:
static ssize_t send_callback(nghttp2_session* session, const uint8_t* data, size_t length, int flags, void* user_data);
static int on_frame_recv_callback(nghttp2_session* session, const nghttp2_frame* frame, void* user_data);
size_t d_outPos{0};
size_t d_inPos{0};
uint32_t d_highestStreamID{0};
+ bool d_healthCheckQuery{false};
};
class DownstreamDoHConnectionsManager
struct timeval now;
gettimeofday(&now, nullptr);
boost::optional<struct timeval> ttd{boost::none};
- if (newState == IOState::NeedRead) {
+ if (d_healthCheckQuery) {
+ ttd = getBackendHealthCheckTTD(now);
+ }
+ else if (newState == IOState::NeedRead) {
ttd = getBackendReadTTD(now);
}
else if (isFresh() && d_queries == 0) {
gettimeofday(&now, nullptr);
auto newConnection = std::make_shared<DoHConnectionToBackend>(ds, mplexer, now);
+ newConnection->setHealthCheck(true);
newConnection->queueQuery(sender, std::move(query));
return true;
#else /* HAVE_NGHTTP2 */
return !d_proxyProtocolPayloadSent && (d_ds && d_ds->useProxyProtocol);
}
+ boost::optional<struct timeval> getBackendHealthCheckTTD(const struct timeval& now) const
+ {
+ if (d_ds == nullptr) {
+ throw std::runtime_error("getBackendReadTTD() without any backend selected");
+ }
+ if (d_ds->checkTimeout == 0) {
+ return boost::none;
+ }
+
+ struct timeval res = now;
+ res.tv_sec += d_ds->checkTimeout;
+
+ return res;
+ }
+
boost::optional<struct timeval> getBackendReadTTD(const struct timeval& now) const
{
if (d_ds == nullptr) {