james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "yadan" <...@css.com.cn>
Subject Re: cvs commit: jakarta-james/src/java/org/apache/james/dnsserver DNSServer.java
Date Thu, 01 Jan 1970 00:00:00 GMT
I must    unsubscribe !!! Please help me!

  

======= 2003-06-19 06:15:00 您在来信中写道:=======

>noel        2003/06/18 23:15:11
>
>  Modified:    src/java/org/apache/james/dnsserver Tag: branch_2_1_fcs
>                        DNSServer.java
>  Log:
>  Added randomization for MX records
>  
>  Revision  Changes    Path
>  No                   revision
>  
>  
>  No                   revision
>  
>  
>  1.9.4.7   +22 -6     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.6
>  retrieving revision 1.9.4.7
>  diff -u -r1.9.4.6 -r1.9.4.7
>  --- DNSServer.java	17 Jun 2003 21:58:23 -0000	1.9.4.6
>  +++ DNSServer.java	19 Jun 2003 06:15:11 -0000	1.9.4.7
>  @@ -355,13 +355,29 @@
>           return answers;
>       }
>   
>  -    private static class MXRecordComparator
>  -        implements Comparator {
>  -
>  +    /* RFC 2821 section 5 requires that we sort the MX records by their
>  +     * preference, and introduce a randomization.  This Comparator does
>  +     * comparisons as normal unless the values are equal, in which case
>  +     * it "tosses a coin", randomly speaking.
>  +     *
>  +     * This way MX record w/preference 0 appears before MX record
>  +     * w/preference 1, but a bunch of MX records with the same preference
>  +     * would appear in different orders each time.
>  +     *
>  +     * Reminder for maintainers: the return value on a Comparator can
>  +     * be counter-intuitive for those who aren't used to the old C
>  +     * strcmp function:
>  +     *
>  +     * < 0 ==> a < b
>  +     * = 0 ==> a = b
>  +     * > 0 ==> a > b
>  +     */
>  +    private static class MXRecordComparator implements Comparator {
>  +        private final static Random random = new Random();
>           public int compare (Object a, Object b) {
>  -            MXRecord ma = (MXRecord)a;
>  -            MXRecord mb = (MXRecord)b;
>  -            return ma.getPriority () - mb.getPriority ();
>  +            int pa = ((MXRecord)a).getPriority();
>  +            int pb = ((MXRecord)b).getPriority();
>  +            return (pa == pb) ? (512 - random.nextInt(1024)) : pa - pb;
>           }
>       }
>   }
>  
>  
>  
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: james-dev-help@jakarta.apache.org

= = = = = = = = = = = = = = = = = = = =
			

                    致
礼!
				 
               yadan
               yxm@css.com.cn
					2003-06-19 



---------------------------------------------------------------------
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