Changeset 1366

Show
Ignore:
Timestamp:
06/24/09 23:11:30 (9 months ago)
Author:
ahu
Message:

implement & document rec_control --timeout feature, useful when (re)loading very large lua scripts

Location:
trunk/pdns/pdns
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/docs/rec_control.1.txt

    r823 r1366  
    4242--socket-pid:: 
    4343        When running in SMP mode, pid of pdns_recursor to control 
     44 
     45--timeout:: 
     46        Number of seconds to wait for the remote PowerDNS Recursor to 
     47        respond. Set to 0 for infinite. 
    4448 
    4549COMMANDS 
  • trunk/pdns/pdns/rec_channel.cc

    r1170 r1366  
    134134  FD_SET( fd, &readfds ); 
    135135 
    136   ret = select( fd + 1, &readfds, NULL, NULL, &tv ); 
     136  ret = select( fd + 1, &readfds, NULL, NULL, (seconds + useconds) ? &tv : 0 ); 
    137137  if ( ret == 0 ) 
    138138    errno = ETIMEDOUT; 
     
    142142 
    143143 
    144 string RecursorControlChannel::recv(std::string* remote) 
     144string RecursorControlChannel::recv(std::string* remote, unsigned int timeout) 
    145145{ 
    146146  char buffer[16384]; 
     
    149149  socklen_t addrlen=sizeof(remoteaddr); 
    150150     
    151   if((waitForData(d_fd, 5, 0 ) != 1) || (len=::recvfrom(d_fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&remoteaddr, &addrlen)) < 0) 
     151  if((waitForData(d_fd, timeout, 0 ) != 1) || (len=::recvfrom(d_fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&remoteaddr, &addrlen)) < 0) 
    152152    throw AhuException("Unable to receive message over control channel: "+string(strerror(errno))); 
    153153 
  • trunk/pdns/pdns/rec_channel.hh

    r1170 r1366  
    3030 
    3131  void send(const std::string& msg, const std::string* remote=0); 
    32   std::string recv(std::string* remote=0); 
     32  std::string recv(std::string* remote=0, unsigned int timeout=5); 
    3333 
    3434  int d_fd; 
  • trunk/pdns/pdns/rec_control.cc

    r1028 r1366  
    3636  arg().set("socket-dir","Where the controlsocket will live")=LOCALSTATEDIR; 
    3737  arg().set("socket-pid","When controlling multiple recursors, the target pid")=""; 
    38  
     38  arg().set("timeout", "Number of seconds to wait for the recursor to respond")="5"; 
    3939  arg().setCmd("help","Provide this helpful message"); 
    4040 
     
    6868  } 
    6969  rccS.send(command); 
    70   string receive=rccS.recv(); 
     70  string receive=rccS.recv(0, arg().asNum("timeout")); 
    7171  cout<<receive; 
    7272  return 0;