]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix TLS session counters for incoming DoH
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 19 Aug 2021 09:06:05 +0000 (11:06 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 13 Sep 2021 13:28:27 +0000 (15:28 +0200)
Increase the 'new' / 'resumed' counters once per connection, not
once per query.

pdns/dnsdistdist/doh.cc

index c479db666c81cde7427ee747feca8f1b8e787d71..97294cf40661e0e920d137d5314400db6861cfba 100644 (file)
@@ -947,16 +947,18 @@ static int doh_handler(h2o_handler_t *self, h2o_req_t *req)
       return 0;
     }
 
-    if (h2o_socket_get_ssl_session_reused(sock) == 0) {
-      ++dsc->cs->tlsNewSessions;
-    }
-    else {
-      ++dsc->cs->tlsResumptions;
-    }
-
     const int descriptor = h2o_socket_get_fd(sock);
     if (descriptor != -1) {
-      ++t_conns.at(descriptor).d_nbQueries;
+      auto& conn = t_conns.at(descriptor);
+      ++conn.d_nbQueries;
+      if (conn.d_nbQueries == 1) {
+        if (h2o_socket_get_ssl_session_reused(sock) == 0) {
+          ++dsc->cs->tlsNewSessions;
+        }
+        else {
+          ++dsc->cs->tlsResumptions;
+        }
+      }
     }
 
     if (auto tlsversion = h2o_socket_get_ssl_protocol_version(sock)) {