hgomez 01/06/22 03:13:55 Modified: jk/java/org/apache/ajp/tomcat33 PoolTcpConnector.java Log: moved isSameAddress to PoolTcpConnector so Ajp12/Ajp13/Ajp14 could have it Revision Changes Path 1.2 +32 -0 jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat33/PoolTcpConnector.java Index: PoolTcpConnector.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/ajp/tomcat33/PoolTcpConnector.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PoolTcpConnector.java 2001/06/09 02:56:22 1.1 +++ PoolTcpConnector.java 2001/06/22 10:13:52 1.2 @@ -263,4 +263,36 @@ // return classN; // } + /** + * Return <code>true</code> if the specified client and server addresses + * are the same. This method works around a bug in the IBM 1.1.8 JVM on + * Linux, where the address bytes are returned reversed in some + * circumstances. + * + * @param server The server's InetAddress + * @param client The client's InetAddress + */ + public static boolean isSameAddress(InetAddress server, InetAddress client) { + // Compare the byte array versions of the two addresses + byte serverAddr[] = server.getAddress(); + byte clientAddr[] = client.getAddress(); + if (serverAddr.length != clientAddr.length) + return (false); + boolean match = true; + for (int i = 0; i < serverAddr.length; i++) { + if (serverAddr[i] != clientAddr[i]) { + match = false; + break; + } + } + if (match) + return (true); + + // Compare the reversed form of the two addresses + for (int i = 0; i < serverAddr.length; i++) { + if (serverAddr[i] != clientAddr[(serverAddr.length-1)-i]) + return (false); + } + return (true); + } }