mina-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mw...@apache.org
Subject svn commit: r550156 - /mina/trunk/core/src/main/java/org/apache/mina/filter/ConnectionThrottleFilter.java
Date Sun, 24 Jun 2007 03:10:47 GMT
Author: mwebb
Date: Sat Jun 23 20:10:46 2007
New Revision: 550156

URL: http://svn.apache.org/viewvc?view=rev&rev=550156
Log:
fixed, or made clear the logic in the isConnectionOk method.

Modified:
    mina/trunk/core/src/main/java/org/apache/mina/filter/ConnectionThrottleFilter.java

Modified: mina/trunk/core/src/main/java/org/apache/mina/filter/ConnectionThrottleFilter.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/ConnectionThrottleFilter.java?view=diff&rev=550156&r1=550155&r2=550156
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/filter/ConnectionThrottleFilter.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/filter/ConnectionThrottleFilter.java Sat
Jun 23 20:10:46 2007
@@ -73,16 +73,32 @@
         this.allowedInterval = allowedInterval;
     }
 
-    private boolean isConnectionOk( IoSession session ){
+    /**
+     * Method responsible for deciding if a connection is OK
+     * to continue
+     * 
+     * @param session
+     * 	The new session that will be verified
+     * @return
+     * 	True if the session meets the criteria, otherwise false
+     */
+    protected boolean isConnectionOk( IoSession session ){
         SocketAddress remoteAddress = session.getRemoteAddress();
         if( remoteAddress instanceof InetSocketAddress )
         {
             long now = System.currentTimeMillis();
             InetSocketAddress addr = (InetSocketAddress)remoteAddress;
+            
             if( clients.containsKey(addr.getAddress().getHostAddress())){
                 Long time = clients.get(addr.getAddress().getHostAddress());
-                if( (now-time) > allowedInterval ){
+                clients.put(addr.getAddress().getHostAddress(), now);
+
+                // if the interval between now and the last connection is 
+                // less than the allowed interval, return false
+                if( (now-time) < allowedInterval ){
                     return false;
+                } else {
+                	return true;
                 }
             } else {
                 clients.put( addr.getAddress().getHostAddress(), now );



Mime
View raw message