You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2014/05/14 11:56:52 UTC

svn commit: r1594529 - /httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java

Author: olegk
Date: Wed May 14 09:56:51 2014
New Revision: 1594529

URL: http://svn.apache.org/r1594529
Log:
Minor performance optimization tweak for pipelining mode

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java?rev=1594529&r1=1594528&r2=1594529&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java Wed May 14 09:56:51 2014
@@ -157,7 +157,16 @@ public class BaseIOReactor extends Abstr
     protected void readable(final SelectionKey key) {
         final IOSession session = getSession(key);
         try {
-            this.eventDispatch.inputReady(session);
+            // Try to gently feed more data to the event dispatcher
+            // if the session input buffer has not been fully exhausted
+            // (the choice of 5 iterations is purely arbitrary)
+            for (int i = 0; i < 5; i++) {
+                this.eventDispatch.inputReady(session);
+                if (!session.hasBufferedInput()
+                        || (session.getEventMask() & SelectionKey.OP_READ) == 0) {
+                    break;
+                }
+            }
             if (session.hasBufferedInput()) {
                 this.bufferingSessions.add(session);
             }