Show
Ignore:
Timestamp:
03/27/06 00:16:00 (7 years ago)
Author:
ahu
Message:

trim some build dependencies, make rec_control/pdns_recursor grok /var/run as place for the controlsocket,
add tcp-questions in all the right places, add callback so 'rec_control quit' gets a response before the program quits

Files:
1 modified

Legend:

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

    r629 r631  
    1212#include <sys/stat.h> 
    1313#include <fcntl.h> 
     14#include "logger.hh" 
    1415 
    1516using namespace std; 
     
    99100  optional<float> delay=g_stats.queryrate.get(now, 10); 
    100101  if(delay) 
    101     return 1000000/(*delay); 
     102    return (uint32_t)(1000000/(*delay)); 
    102103  else 
    103104    return 0; 
     
    106107RecursorControlParser::RecursorControlParser() 
    107108{ 
    108   extern uint64_t qcounter; 
    109   addGetStat("questions", &qcounter); 
     109  addGetStat("questions", &g_stats.qcounter); 
     110  addGetStat("tcp-questions", &g_stats.tcpqcounter); 
    110111 
    111112  addGetStat("cache-hits", &RC.cacheHits); 
     
    125126  addGetStat("qa-latency", &g_stats.avgLatencyUsec); 
    126127 
    127   addGetStat("all-questions", &qcounter); 
    128128  addGetStat("negcache-entries", boost::bind(&SyncRes::negcache_t::size, ref(SyncRes::s_negcache))); 
    129129  addGetStat("throttle-entries", boost::bind(&SyncRes::throttle_t::size, ref(SyncRes::s_throttle))); 
     
    140140} 
    141141 
    142 string RecursorControlParser::getAnswer(const string& question) 
     142static void doExit() 
    143143{ 
     144  L<<Logger::Error<<"Exiting on user request"<<endl; 
     145  exit(1); 
     146} 
     147 
     148string RecursorControlParser::getAnswer(const string& question, RecursorControlParser::func_t** command) 
     149{ 
     150  *command=nop; 
    144151  vector<string> words; 
    145152  stringtok(words, question); 
    146153 
    147154  if(words.empty()) 
    148     return "invalid command"; 
     155    return "invalid command\n"; 
    149156 
    150157  string cmd=toLower(words[0]); 
     
    154161    return doGet(begin, end); 
    155162 
    156   if(cmd=="quit")  
    157     exit(1); 
     163  if(cmd=="quit") { 
     164    *command=&doExit; 
     165    return "bye\n"; 
     166  } 
    158167 
    159168  if(cmd=="dump-cache")