Show
Ignore:
Timestamp:
06/13/10 23:10:32 (3 years ago)
Author:
ahu
Message:

lua scripts can now indicate that a query has a 'variable' answer, which means that it will not get cached, even if lua did not otherwise touch the answer.. because it might have!
use 'setvariable()' from the lua hooks to indicate this.

Files:
1 modified

Legend:

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

    r1630 r1636  
    512512    int res; 
    513513 
    514     if(!t_pdl->get() || !(*t_pdl)->preresolve(dc->d_remote, g_listenSocketsAddresses[dc->d_socket], dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res)) { 
     514    bool variableAnswer = false; 
     515    if(!t_pdl->get() || !(*t_pdl)->preresolve(dc->d_remote, g_listenSocketsAddresses[dc->d_socket], dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res, &variableAnswer)) { 
    515516       res = sr.beginResolve(dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), dc->d_mdp.d_qclass, ret); 
    516517 
    517518      if(t_pdl->get()) { 
    518519        if(res == RCode::NXDomain) 
    519           (*t_pdl)->nxdomain(dc->d_remote, g_listenSocketsAddresses[dc->d_socket], dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res); 
     520          (*t_pdl)->nxdomain(dc->d_remote, g_listenSocketsAddresses[dc->d_socket], dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res, &variableAnswer); 
    520521      } 
    521522    } 
     523     
    522524    uint32_t minTTL=numeric_limits<uint32_t>::max(); 
    523525    if(res<0) { 
     
    558560    if(!dc->d_tcp) { 
    559561      sendto(dc->d_socket, (const char*)&*packet.begin(), packet.size(), 0, (struct sockaddr *)(&dc->d_remote), dc->d_remote.getSocklen()); 
    560       if(!SyncRes::s_nopacketcache) { 
     562      if(!SyncRes::s_nopacketcache && !variableAnswer ) { 
    561563        t_packetCache->insertResponsePacket(string((const char*)&*packet.begin(), packet.size()), g_now.tv_sec,  
    562564                                           min(minTTL,  
    563                                                pw.getHeader()->rcode == RCode::ServFail ? SyncRes::s_packetcacheservfailttl : SyncRes::s_packetcachettl 
    564                                                ) 
     565                                               (pw.getHeader()->rcode == RCode::ServFail) ? SyncRes::s_packetcacheservfailttl : SyncRes::s_packetcachettl 
     566                                               )  
    565567                                          ); 
    566568      } 
     
    14131415      g_stats.unexpectedCount++; // if we made it here, it really is an unexpected answer 
    14141416      if(g_logCommonErrors) 
    1415         L<<Logger::Warning<<"Discarding unexpected packet from "<<fromaddr.toString()<<": "<<pident.domain<<", "<<pident.type<<endl; 
     1417        L<<Logger::Warning<<"Discarding unexpected packet from "<<fromaddr.toStringWithPort()<<": "<<pident.domain<<", "<<pident.type<<endl; 
    14161418    } 
    14171419    else if(fd >= 0) {