Changeset 723

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

fix duplicate return of sockets to the pool, improve tcp timeout message

Files:
1 modified

Legend:

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

    r722 r723  
    255255  void returnSocket(socks_t::iterator& i) 
    256256  { 
     257    if(i==d_socks.end()) { 
     258      throw AhuException("Trying to return a socket not in the pool"); 
     259    } 
    257260    g_fdm->removeReadFD(i->first); 
    258261    ::close(i->first); 
     
    10441047void handleUDPServerResponse(int fd, boost::any& var) 
    10451048{ 
    1046   PacketID& pid=any_cast<PacketID&>(var); 
     1049  PacketID pid=any_cast<PacketID>(var); 
    10471050  int len; 
    10481051  char data[1500]; 
     
    10511054 
    10521055  len=recvfrom(fd, data, sizeof(data), 0, (sockaddr *)&fromaddr, &addrlen); 
    1053   g_udpclientsocks.returnSocket(fd); 
     1056 
    10541057 
    10551058  if(len < (int)sizeof(dnsheader)) { 
     
    10631066    } 
    10641067    string empty; 
     1068    g_udpclientsocks.returnSocket(fd); 
    10651069    MT->sendEvent(pid, &empty); // this denotes error 
    10661070    return; 
     
    10971101    L<<Logger::Warning<<"Ignoring question on outgoing socket from "<< sockAddrToString((struct sockaddr_in*) &fromaddr, addrlen)  <<endl; 
    10981102} 
    1099  
    1100 #if 0 
    1101 // this code sweeps all running tcp connections for timeouts, it didn't survive move to multiplexer 
    1102       vector<TCPConnection> sweeped; 
    1103  
    1104       for(vector<TCPConnection>::iterator i=g_tcpconnections.begin();i!=g_tcpconnections.end();++i) { 
    1105         if(i->state==TCPConnection::DONE || g_now.tv_sec < i->startTime + tcpTimeout) {  // don't timeout when we are working on the question! 
    1106           sweeped.push_back(*i); 
    1107           if(i->state!=TCPConnection::DONE) { // we don't listen for data when we are processing the question 
    1108             FD_SET(i->fd, &readfds); 
    1109             fdmax=max(fdmax,i->fd); 
    1110           } 
    1111         } 
    1112         else { 
    1113           if(g_logCommonErrors) 
    1114             L<<Logger::Error<<"TCP timeout from client "<<inet_ntoa(i->remote.sin_addr)<<endl; 
    1115           i->closeAndCleanup(); 
    1116         } 
    1117       } 
    1118       sweeped.swap(g_tcpconnections); 
    1119 #endif 
    11201103 
    11211104FDMultiplexer* getMultiplexer() 
     
    13071290          TCPConnection conn=any_cast<TCPConnection>(i->second); 
    13081291          if(conn.state != TCPConnection::DONE) { 
     1292            if(g_logCommonErrors) 
     1293              L<<Logger::Warning<<"Timeout from remote TCP client "<<sockAddrToString(&conn.remote,sizeof(conn.remote))<<endl; 
    13091294            g_fdm->removeReadFD(i->first); 
    13101295            conn.closeAndCleanup(); 
     
    13211306      gettimeofday(&g_now, 0); 
    13221307      g_fdm->run(&g_now); 
    1323  
    13241308 
    13251309      if(listenOnTCP) {