Changeset 1511

Show
Ignore:
Timestamp:
02/06/10 20:53:47 (3 years ago)
Author:
ahu
Message:

reinstate top-remotes

Location:
trunk/pdns/pdns
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/pdns_recursor.cc

    r1508 r1511  
    7575bool g_logCommonErrors; 
    7676__thread shared_ptr<PowerDNSLua>* t_pdl; 
     77__thread RemoteKeeper* t_remotes; 
    7778 
    7879RecursorControlChannel s_rcc; // only active in thread 0 
     
    759760    } 
    760761 
    761     g_stats.addRemote(addr); 
     762    t_remotes->addRemote(addr); 
    762763    if(t_allowFrom && !t_allowFrom->match(&addr)) { 
    763764      if(!g_quiet)  
     
    800801  if((len=recvfrom(fd, data, sizeof(data), 0, (sockaddr *)&fromaddr, &addrlen)) >= 0) { 
    801802 
    802     g_stats.addRemote(fromaddr); 
     803    t_remotes->addRemote(fromaddr); 
    803804 
    804805    if(t_allowFrom && !t_allowFrom->match(&fromaddr)) { 
     
    11761177} 
    11771178 
     1179vector<ComboAddress>& operator+=(vector<ComboAddress>&a, const vector<ComboAddress>& b) 
     1180{ 
     1181  a.insert(a.end(), b.begin(), b.end()); 
     1182  return a; 
     1183} 
     1184 
     1185 
     1186 
    11781187template<class T> T broadcastAccFunction(const boost::function<T*()>& func, bool skipSelf) 
    11791188{ 
     
    12131222template string broadcastAccFunction(const boost::function<string*()>& fun, bool skipSelf); // explicit instantiation 
    12141223template uint64_t broadcastAccFunction(const boost::function<uint64_t*()>& fun, bool skipSelf); // explicit instantiation 
     1224template vector<ComboAddress> broadcastAccFunction(const boost::function<vector<ComboAddress> *()>& fun, bool skipSelf); // explicit instantiation 
    12151225 
    12161226void handleRCC(int fd, FDMultiplexer::funcparam_t& var) 
     
    16181628  g_initialDomainMap = parseAuthAndForwards(); 
    16191629  
    1620   //  g_stats.remotes.resize(::arg().asNum("remotes-ringbuffer-entries")); XXX FIXME NEEDS TO BE REDONE FOR "MULTITHREADING" 
    1621   if(!g_stats.remotes.empty()) 
    1622     memset(&g_stats.remotes[0], 0, g_stats.remotes.size() * sizeof(RecursorStats::remotes_t::value_type)); 
     1630     
    16231631  g_logCommonErrors=::arg().mustDo("log-common-errors"); 
    16241632   
     
    17031711    exit(99); 
    17041712  } 
     1713   
     1714  t_remotes = new RemoteKeeper(); 
     1715  t_remotes->remotes.resize(::arg().asNum("remotes-ringbuffer-entries") / g_numThreads);  
     1716   
     1717  if(!t_remotes->remotes.empty()) 
     1718    memset(&t_remotes->remotes[0], 0, t_remotes->remotes.size() * sizeof(RemoteKeeper::remotes_t::value_type)); 
     1719   
    17051720   
    17061721  MT=new MTasker<PacketID,string>(::arg().asNum("stack-size")); 
  • trunk/pdns/pdns/rec_channel_rec.cc

    r1510 r1511  
    433433} 
    434434 
     435vector<ComboAddress>* pleaseGetRemotes() 
     436{ 
     437  return new vector<ComboAddress>(t_remotes->remotes); 
     438} 
    435439 
    436440string doTopRemotes() 
     
    438442  typedef map<ComboAddress, int, ComboAddress::addressOnlyLessThan> counts_t; 
    439443  counts_t counts; 
    440    
     444 
     445  vector<ComboAddress> remotes=broadcastAccFunction<vector<ComboAddress> >(pleaseGetRemotes); 
     446     
    441447  unsigned int total=0; 
    442   for(RecursorStats::remotes_t::const_iterator i=g_stats.remotes.begin(); i != g_stats.remotes.end(); ++i) 
     448  for(RemoteKeeper::remotes_t::const_iterator i = remotes.begin(); i != remotes.end(); ++i) 
    443449    if(i->sin4.sin_family) { 
    444450      total++; 
  • trunk/pdns/pdns/syncres.hh

    r1507 r1511  
    453453typedef MTasker<PacketID,string> MT_t; 
    454454extern __thread MT_t* MT; 
     455 
    455456 
    456457struct RecursorStats 
     
    481482  uint64_t packetCacheHits; 
    482483  time_t startupTime; 
    483  
     484}; 
     485 
     486struct RemoteKeeper 
     487{ 
    484488  typedef vector<ComboAddress> remotes_t; 
    485489  remotes_t remotes; 
     
    493497  } 
    494498}; 
    495  
     499extern __thread RemoteKeeper* t_remotes; 
    496500string doQueueReloadLuaScript(vector<string>::const_iterator begin, vector<string>::const_iterator end); 
    497501void parseACLs();