Author: norman
Date: Mon Jun 20 10:19:50 2011
New Revision: 1137589
URL: http://svn.apache.org/viewvc?rev=1137589&view=rev
Log:
Correctly count connections for limit them. Thanks to TzeKai Lee for the patch.
See PROTOCOLS-23
Modified:
james/protocols/trunk/impl/src/main/java/org/jboss/netty/handler/connection/ConnectionLimitUpstreamHandler.java
james/protocols/trunk/impl/src/main/java/org/jboss/netty/handler/connection/ConnectionPerIpLimitUpstreamHandler.java
Modified:
james/protocols/trunk/impl/src/main/java/org/jboss/netty/handler/connection/ConnectionLimitUpstreamHandler.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/impl/src/main/java/org/jboss/netty/handler/connection/ConnectionLimitUpstreamHandler.java?rev=1137589&r1=1137588&r2=1137589&view=diff
==============================================================================
---
james/protocols/trunk/impl/src/main/java/org/jboss/netty/handler/connection/ConnectionLimitUpstreamHandler.java
(original)
+++
james/protocols/trunk/impl/src/main/java/org/jboss/netty/handler/connection/ConnectionLimitUpstreamHandler.java
Mon Jun 20 10:19:50 2011
@@ -54,11 +54,10 @@ public class ConnectionLimitUpstreamHand
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
throws Exception {
if (maxConnections > 0) {
- int currentCount = connections.getAndIncrement();
+ int currentCount = connections.incrementAndGet();
if (currentCount > maxConnections) {
ctx.getChannel().close();
- connections.decrementAndGet();
}
}
Modified:
james/protocols/trunk/impl/src/main/java/org/jboss/netty/handler/connection/ConnectionPerIpLimitUpstreamHandler.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/impl/src/main/java/org/jboss/netty/handler/connection/ConnectionPerIpLimitUpstreamHandler.java?rev=1137589&r1=1137588&r2=1137589&view=diff
==============================================================================
---
james/protocols/trunk/impl/src/main/java/org/jboss/netty/handler/connection/ConnectionPerIpLimitUpstreamHandler.java
(original)
+++
james/protocols/trunk/impl/src/main/java/org/jboss/netty/handler/connection/ConnectionPerIpLimitUpstreamHandler.java
Mon Jun 20 10:19:50 2011
@@ -80,7 +80,6 @@ public class ConnectionPerIpLimitUpstrea
Integer count = atomicCount.incrementAndGet();
if (count > maxConnectionsPerIp) {
ctx.getChannel().close();
- atomicCount.decrementAndGet();
}
}
}
@@ -101,4 +100,4 @@ public class ConnectionPerIpLimitUpstrea
}
super.channelClosed(ctx, e);
}
-}
\ No newline at end of file
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]