james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject cvs commit: jakarta-james/src/java/org/apache/james/dnsserver DNSServer.java
Date Mon, 16 Jun 2003 03:16:46 GMT
noel        2003/06/15 20:16:46

  Modified:    src/java/org/apache/james/dnsserver Tag: branch_2_1_fcs
                        DNSServer.java
  Log:
  Fix to handle TTL 0 records
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.9.4.5   +25 -18    jakarta-james/src/java/org/apache/james/dnsserver/DNSServer.java
  
  Index: DNSServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/dnsserver/DNSServer.java,v
  retrieving revision 1.9.4.4
  retrieving revision 1.9.4.5
  diff -u -r1.9.4.4 -r1.9.4.5
  --- DNSServer.java	6 Jun 2003 16:37:15 -0000	1.9.4.4
  +++ DNSServer.java	16 Jun 2003 03:16:46 -0000	1.9.4.5
  @@ -285,30 +285,14 @@
           }
           short dclass = DClass.IN;
   
  -        Record [] answers;
  -        int answerCount = 0, n = 0;
  -
           SetResponse cached = cache.lookupRecords(name, type, dnsCredibility);
           if (cached.isSuccessful()) {
               getLogger().debug(new StringBuffer(256)
                                .append("Retrieving MX record for ")
                                .append(name).append(" from cache")
                                .toString());
  -            RRset [] rrsets = cached.answers();
  -            answerCount = 0;
  -            for (int i = 0; i < rrsets.length; i++) {
  -                answerCount += rrsets[i].size();
  -            }
   
  -            answers = new Record[answerCount];
  -
  -            for (int i = 0; i < rrsets.length; i++) {
  -                Iterator iter = rrsets[i].rrs();
  -                while (iter.hasNext()) {
  -                    Record r = (Record)iter.next();
  -                    answers[n++] = r;
  -                }
  -            }
  +            return processSetResponse(cached);
           }
           else if (cached.isNXDOMAIN() || cached.isNXRRSET()) {
               return null;
  @@ -335,7 +319,10 @@
   
               short rcode = response.getHeader().getRcode();
               if (rcode == Rcode.NOERROR || rcode == Rcode.NXDOMAIN) {
  -                cache.addMessage(response);
  +                cached = cache.addMessage(response);
  +                if (cached != null) {
  +                    return processSetResponse(cached);
  +                }
               }
   
               if (rcode != Rcode.NOERROR) {
  @@ -344,7 +331,27 @@
   
               return rawDNSLookup(namestr, true, type);
           }
  +    }
  +    
  +    private Record[] processSetResponse(SetResponse sr) {
  +        Record [] answers;
  +        int answerCount = 0, n = 0;
  +
  +        RRset [] rrsets = sr.answers();
  +        answerCount = 0;
  +        for (int i = 0; i < rrsets.length; i++) {
  +            answerCount += rrsets[i].size();
  +        }
   
  +        answers = new Record[answerCount];
  +
  +        for (int i = 0; i < rrsets.length; i++) {
  +            Iterator iter = rrsets[i].rrs();
  +            while (iter.hasNext()) {
  +                Record r = (Record)iter.next();
  +                answers[n++] = r;
  +            }
  +        }
           return answers;
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org


Mime
View raw message