• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PowerDNS / pdns / 19202600185

09 Nov 2025 03:18AM UTC coverage: 73.052% (+0.06%) from 72.995%
19202600185

Pull #16459

github

web-flow
Merge 423666510 into f324028a2
Pull Request #16459: Fix try/except/as notation

38311 of 63074 branches covered (60.74%)

Branch coverage included in aggregate %.

127423 of 163798 relevant lines covered (77.79%)

12342679.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

53.15
/pdns/statnode.cc
1
#include "statnode.hh"
2

3
StatNode::Stat StatNode::print(unsigned int depth, Stat newstat, bool silent) const
4
{
×
5
  if(!silent) {
×
6
    cout<<string(depth, ' ');
×
7
    cout<<name<<": "<<endl;
×
8
  }
×
9
  Stat childstat;
×
10
  childstat.queries += s.queries;
×
11
  childstat.noerrors += s.noerrors;
×
12
  childstat.nxdomains += s.nxdomains;
×
13
  childstat.servfails += s.servfails;
×
14
  childstat.drops += s.drops;
×
15
  childstat.bytes += s.bytes;
×
16
  childstat.hits += s.hits;
×
17

18
  if(children.size()>1024 && !silent) {
×
19
    cout<<string(depth, ' ')<<name<<": too many to print"<<endl;
×
20
  }
×
21
  for(const children_t::value_type& child :  children) {
×
22
    childstat=child.second.print(depth+8, childstat, silent || children.size()>1024);
×
23
  }
×
24
  if(!silent || children.size()>1)
×
25
    cout<<string(depth, ' ')<<childstat.queries<<" queries, " << 
×
26
      childstat.noerrors<<" noerrors, "<< 
×
27
      childstat.nxdomains<<" nxdomains, "<< 
×
28
      childstat.servfails<<" servfails, "<< 
×
29
      childstat.drops<<" drops, "<<
×
30
      childstat.bytes<<" bytes, "<<
×
31
      childstat.hits<<" hits"<<endl;
×
32

33
  newstat+=childstat;
×
34

35
  return newstat;
×
36
}
×
37

38
void StatNode::visit(const visitor_t& visitor, Stat& newstat, unsigned int depth) const
39
{
2,119✔
40
  Stat childstat(s);
2,119✔
41

42
  for (const auto& child : children) {
2,119✔
43
    child.second.visit(visitor, childstat, depth+8);
2,104✔
44
  }
2,104✔
45

46
  visitor(this, s, childstat);
2,119✔
47

48
  newstat += childstat;
2,119✔
49
}
2,119✔
50

51
void StatNode::submit(const DNSName& domain, int rcode, unsigned int bytes, bool hit, const std::optional<ComboAddress>& remote)
52
{
2,055✔
53
  //  cerr<<"FIRST submit called on '"<<domain<<"'"<<endl;
54
  std::vector<string> tmp = domain.getRawLabels();
2,055✔
55
  if (tmp.empty()) {
2,055!
56
    return;
×
57
  }
×
58

59
  auto last = tmp.end() - 1;
2,055✔
60
  children[*last].submit(last, tmp.begin(), "", rcode, bytes, remote, 1, hit);
2,055✔
61
}
2,055✔
62

63
/* www.powerdns.com. -> 
64
   .                 <- fullnames
65
   com.
66
   powerdns.com
67
   www.powerdns.com. 
68
*/
69

70
void StatNode::submit(std::vector<string>::const_iterator end, std::vector<string>::const_iterator begin, const std::string& domain, int rcode, unsigned int bytes, const std::optional<ComboAddress>& remote, unsigned int count, bool hit)
71
{
8,230✔
72
  //  cerr<<"Submit called for domain='"<<domain<<"': ";
73
  //  for(const std::string& n :  labels) 
74
  //    cerr<<n<<".";
75
  //  cerr<<endl;
76
  if (name.empty()) {
8,230✔
77

78
    name=*end;
2,104✔
79
    //    cerr<<"Set short name to '"<<name<<"'"<<endl;
80
  }
2,104✔
81
  else {
6,126✔
82
    //    cerr<<"Short name was already set to '"<<name<<"'"<<endl;
83
  }
6,126✔
84

85
  if (end == begin) {
8,230✔
86
    if (fullname.empty()) {
2,055✔
87
      size_t needed = name.size() + 1 + domain.size();
2,054✔
88
      if (fullname.capacity() < needed) {
2,054!
89
        fullname.reserve(needed);
2,054✔
90
      }
2,054✔
91
      fullname = name;
2,054✔
92
      fullname.append(".");
2,054✔
93
      fullname.append(domain);
2,054✔
94
      labelsCount = count;
2,054✔
95
    }
2,054✔
96
    //    cerr<<"Hit the end, set our fullname to '"<<fullname<<"'"<<endl<<endl;
97
    s.queries++;
2,055✔
98
    s.bytes += bytes;
2,055✔
99
    if (rcode < 0) {
2,055!
100
      s.drops++;
×
101
    }
×
102
    else if (rcode == RCode::NoError) {
2,055!
103
      s.noerrors++;
2,055✔
104
    }
2,055✔
105
    else if (rcode == RCode::ServFail) {
×
106
      s.servfails++;
×
107
    }
×
108
    else if (rcode == RCode::NXDomain) {
×
109
      s.nxdomains++;
×
110
    }
×
111

112
    if (remote) {
2,055!
113
      s.remotes[*remote]++;
×
114
    }
×
115

116
    if (hit) {
2,055✔
117
      ++s.hits;
3✔
118
    }
3✔
119
  }
2,055✔
120
  else {
6,175✔
121
    if (fullname.empty()) {
6,175✔
122
      size_t needed = name.size() + 1 + domain.size();
50✔
123
      if (fullname.capacity() < needed) {
50✔
124
        fullname.reserve(needed);
22✔
125
      }
22✔
126
      fullname = name;
50✔
127
      fullname.append(".");
50✔
128
      fullname.append(domain);
50✔
129
      labelsCount = count;
50✔
130
    }
50✔
131
    //    cerr<<"Not yet end, set our fullname to '"<<fullname<<"', recursing"<<endl;
132
    --end;
6,175✔
133
    children[*end].submit(end, begin, fullname, rcode, bytes, remote, count+1, hit);
6,175✔
134
  }
6,175✔
135
}
8,230✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc