ningyu1 closed pull request #2437: [Dubbo-2328]Fix the concurrency limit of 
'ActiveLimitFilter' to calculate atomicity
URL: https://github.com/apache/incubator-dubbo/pull/2437
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java
index 7f7aff8024..e684a82923 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java
@@ -42,9 +42,9 @@ public Result invoke(Invoker<?> invoker, Invocation 
invocation) throws RpcExcept
             long timeout = 
invoker.getUrl().getMethodParameter(invocation.getMethodName(), 
Constants.TIMEOUT_KEY, 0);
             long start = System.currentTimeMillis();
             long remain = timeout;
-            int active = count.getActive();
-            if (active >= max) {
-                synchronized (count) {
+            synchronized (count) {
+                int active = count.getActive();
+                if (active >= max) {
                     while ((active = count.getActive()) >= max) {
                         try {
                             count.wait(remain);
@@ -61,11 +61,13 @@ public Result invoke(Invoker<?> invoker, Invocation 
invocation) throws RpcExcept
                         }
                     }
                 }
+                RpcStatus.beginCount(url, methodName);
             }
+        } else {
+            RpcStatus.beginCount(url, methodName);
         }
         try {
             long begin = System.currentTimeMillis();
-            RpcStatus.beginCount(url, methodName);
             try {
                 Result result = invoker.invoke(invocation);
                 RpcStatus.endCount(url, methodName, System.currentTimeMillis() 
- begin, true);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to