Changeset 722

Show
Ignore:
Timestamp:
04/18/06 14:18:02 (7 years ago)
Author:
ahu
Message:

fix timeouts of running TCP client queries - we shouldn't time them out while we are still working!

Location:
trunk/pdns/pdns
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/mplexer.hh

    r720 r722  
    7878  } 
    7979 
     80  virtual boost::any& getReadParameter(int fd)  
     81  { 
     82    if(!d_readCallbacks.count(fd)) 
     83      throw FDMultiplexerException("attempt to look up data in multiplexer for unlisted fd "+boost::lexical_cast<std::string>(fd)); 
     84    return d_readCallbacks[fd].d_parameter; 
     85  } 
     86 
    8087  virtual std::vector<std::pair<int, boost::any> > getTimeouts(const struct timeval& tv) 
    8188  { 
     
    97104   
    98105  virtual std::string getName() = 0; 
     106 
    99107 
    100108protected: 
  • trunk/pdns/pdns/pdns_recursor.cc

    r721 r722  
    526526        g_fdm->removeReadFD(dc->d_socket); 
    527527        close(dc->d_socket); 
    528         // i->closeAndCleanup(); // XXX we don't remove ourselves from the list anymore  
    529       } 
    530       else  
    531         ; // XXX FIXME, need to restore resetting connection to BYTE0 in case of noerror! 
    532  
    533 #if 0 
    534       for(vector<TCPConnection>::iterator i=g_tcpconnections.begin();i!=g_tcpconnections.end();++i) { 
    535         if(i->fd == dc->d_socket) { 
    536           if(hadError) { 
    537             i->closeAndCleanup(); 
    538             g_tcpconnections.erase(i); 
    539           } 
    540           else { 
    541             i->state=TCPConnection::BYTE0; 
    542             i->startTime=time(0); // needs to be current, TCP is slow anyhow 
    543           } 
    544           break; 
    545         } 
    546       } 
    547 #endif 
     528      } 
     529      else { 
     530        any_cast<TCPConnection&>(g_fdm->getReadParameter(dc->d_socket)).state=TCPConnection::BYTE0; 
     531        struct timeval now;  
     532        gettimeofday(&now, 0); // needs to be updated 
     533        g_fdm->setReadTTD(dc->d_socket, now, g_tcpTimeout); 
     534      } 
    548535    } 
    549536 
     
    646633    conn.bytesread+=bytes; 
    647634    if(conn.bytesread==conn.qlen) { 
    648       //      conn.state=TCPConnection::DONE; // this makes us immune from timeouts, from now on *we* are responsible 
    649       conn.state=TCPConnection::BYTE0; // *wrong* - yes, we want to listen for a new question already, but we shouldn't timeout etc 
     635      conn.state=TCPConnection::DONE;        // this makes us immune from timeouts, from now on *we* are responsible 
    650636      DNSComboWriter* dc=0; 
    651637      try { 
     
    13141300      } 
    13151301 
    1316       if(!(counter%1)) { 
     1302      if(!(counter%11)) { 
    13171303        typedef vector<pair<int, boost::any> > expired_t; 
    13181304        expired_t expired=g_fdm->getTimeouts(g_now); 
     
    13201306        for(expired_t::iterator i=expired.begin() ; i != expired.end(); ++i) { 
    13211307          TCPConnection conn=any_cast<TCPConnection>(i->second); 
    1322           g_fdm->removeReadFD(i->first); 
    1323           cerr<<"Closed connection with our client "<<i->first<<"\n"; 
    1324           conn.closeAndCleanup(); 
     1308          if(conn.state != TCPConnection::DONE) { 
     1309            g_fdm->removeReadFD(i->first); 
     1310            conn.closeAndCleanup(); 
     1311          } 
    13251312        } 
    13261313      }