~ubuntu-branches/ubuntu/maverick/pdns/maverick-updates

« back to all changes in this revision

Viewing changes to pdns/syncres.hh

  • Committer: Bazaar Package Importer
  • Author(s): Debian PowerDNS Maintainers
  • Date: 2006-05-06 10:40:44 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060506104044-v9hczzfl7dcri6qt
Tags: 2.9.20-3
Disable the recursor, this is in a separate package now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#include "misc.hh"
13
13
#include "lwres.hh"
14
14
#include <boost/utility.hpp>
 
15
#include "recursor_cache.hh"
15
16
 
16
17
/* external functions, opaque to us */
17
18
 
64
65
    } 
65
66
    else if(i->second.ttd > e.ttd || (i->second.count) < e.count) 
66
67
      d_cont[t]=e;
67
 
 
 
68
  }
 
69
  
 
70
  unsigned int size()
 
71
  {
 
72
    return d_cont.size();
68
73
  }
69
74
private:
70
75
  int d_limit;
98
103
 
99
104
  void submit(int val, struct timeval*tv = 0)
100
105
  {
101
 
    double now;
 
106
    float now;
102
107
    if(tv)
103
108
      now=tv->tv_sec + tv->tv_usec/1000000.0;
104
109
    else
105
110
      now=getTime();
106
111
 
107
 
    double diff=d_last-now;
 
112
    float diff=d_last-now;
108
113
    d_last=now;
109
 
    double factor=exp(diff)/2.0; // might be '0.5', or 0.0001
 
114
    float factor=exp(diff)/2.0; // might be '0.5', or 0.0001
110
115
    d_val=(1-factor)*val+ factor*d_val; 
111
116
  }
112
117
 
113
 
  double get(struct timeval*tv = 0)
 
118
  float get(struct timeval*tv = 0)
114
119
  {
115
 
    double now;
 
120
    float now;
116
121
    if(tv)
117
122
      now=tv->tv_sec + tv->tv_usec/1000000.0;
118
123
    else
119
124
      now=getTime();
120
125
 
121
 
    double diff=d_lastget-now;
 
126
    float diff=d_lastget-now;
122
127
    d_lastget=now;
123
 
    double factor=exp(diff/60.0); // is 1.0 or less
 
128
    float factor=exp(diff/60.0); // is 1.0 or less
124
129
    return d_val*=factor;
125
130
  }
126
131
 
 
132
  bool stale(time_t limit) 
 
133
  {
 
134
    return limit > d_lastget;
 
135
  }
 
136
 
127
137
private:
128
138
  DecayingEwma& operator=(const DecayingEwma&);
129
 
  double d_last;
130
 
  double d_lastget;
131
 
  double d_val;
 
139
  float d_last;
 
140
  float d_lastget;
 
141
  float d_val;
132
142
};
133
143
 
134
144
 
139
149
  int beginResolve(const string &qname, const QType &qtype, vector<DNSResourceRecord>&ret);
140
150
  void setId(int id)
141
151
  {
142
 
    d_prefix="["+itoa(id)+"] ";
 
152
    if(s_log)
 
153
      d_prefix="["+itoa(id)+"] ";
143
154
  }
144
155
  static void setLog(bool log)
145
156
  {
163
174
  unsigned int d_tcpoutqueries;
164
175
  unsigned int d_throttledqueries;
165
176
  unsigned int d_timeouts;
166
 
  static map<string,NegCacheEntry> s_negcache;    
 
177
  typedef map<string,NegCacheEntry> negcache_t;
 
178
  static negcache_t s_negcache;    
 
179
 
 
180
  typedef map<string,DecayingEwma> nsspeeds_t;
 
181
  static nsspeeds_t s_nsSpeeds;
 
182
 
167
183
  static Throttle<string> s_throttle;
168
184
private:
169
185
  struct GetBestNSAnswer;
179
195
 
180
196
  inline vector<string> shuffle(set<string> &nameservers, const string &prefix);
181
197
  bool moreSpecificThan(const string& a, const string &b);
182
 
  string getA(const string &qname, int depth, set<GetBestNSAnswer>& beenthere);
 
198
  vector<string> getAs(const string &qname, int depth, set<GetBestNSAnswer>& beenthere);
183
199
 
184
200
  SyncRes(const SyncRes&);
185
201
  SyncRes& operator=(const SyncRes&);