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 2018/11/18 18:27:05 UTC

httpcomponents-core git commit: Removed output performance optimization in HTTP/1.1 async protocol handlers

Repository: httpcomponents-core
Updated Branches:
  refs/heads/master 93f61318f -> 6a5eba5e5


Removed output performance optimization in HTTP/1.1 async protocol handlers


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/6a5eba5e
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/6a5eba5e
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/6a5eba5e

Branch: refs/heads/master
Commit: 6a5eba5e50f1add143ebbc05636471ff7413d1f5
Parents: 93f6131
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Nov 18 19:11:37 2018 +0100
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Nov 18 19:23:00 2018 +0100

----------------------------------------------------------------------
 .../http/impl/nio/AbstractHttp1StreamDuplexer.java | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/6a5eba5e/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
index 1ee2333..feb3000 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
@@ -98,7 +98,6 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
     private final AtomicInteger inputWindow;
     private final ByteBuffer contentBuffer;
     private final Lock outputLock;
-    private final AtomicInteger outputRequests;
 
     private volatile Message<IncomingMessage, ContentDecoder> incomingMessage;
     private volatile Message<OutgoingMessage, ContentEncoder> outgoingMessage;
@@ -135,7 +134,6 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
         this.inputWindow = new AtomicInteger(0);
         this.contentBuffer = ByteBuffer.allocate(this.h1Config.getBufferSize());
         this.outputLock = new ReentrantLock();
-        this.outputRequests = new AtomicInteger(0);
         this.connState = ConnectionState.READY;
     }
 
@@ -377,21 +375,18 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
             if (isOutputReady()) {
                 produceOutput();
             } else {
-                final int pendingOutputRequests = outputRequests.get();
                 outputLock.lock();
                 try {
-                    if (!outbuf.hasData() && outputRequests.compareAndSet(pendingOutputRequests, 0)) {
+                    if (!outbuf.hasData()) {
                         ioSession.clearEvent(SelectionKey.OP_WRITE);
-                    } else {
-                        outputRequests.addAndGet(-pendingOutputRequests);
                     }
                 } finally {
                     outputLock.unlock();
                 }
             }
 
-            outputLock.lock();
             final boolean outputEnd;
+            outputLock.lock();
             try {
                 outputEnd = outgoingMessage == null && !outbuf.hasData();
             } finally {
@@ -502,8 +497,12 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
     }
 
     void requestSessionOutput() {
-        outputRequests.incrementAndGet();
-        ioSession.setEvent(SelectionKey.OP_WRITE);
+        outputLock.lock();
+        try {
+            ioSession.setEvent(SelectionKey.OP_WRITE);
+        } finally {
+            outputLock.unlock();
+        }
     }
 
     Timeout getSessionTimeout() {