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 2020/11/05 21:06:38 UTC

[httpcomponents-core] 02/06: Calculate pendingOutputRequests before calling produceOutput to avoid race condition

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch 5.0.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit 95f599cb193587e951376342c177139d1c095f60
Author: ColinWeld <c_...@backblaze.com>
AuthorDate: Thu Sep 24 17:25:16 2020 -0700

    Calculate pendingOutputRequests before calling produceOutput to avoid race condition
---
 .../org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 1fcfe5e..d8b27d6 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
@@ -346,8 +346,8 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
             ioSession.getLock().unlock();
         }
         if (connState.compareTo(ConnectionState.SHUTDOWN) < 0) {
-            produceOutput();
             final int pendingOutputRequests = outputRequests.get();
+            produceOutput();
             final boolean outputPending = isOutputReady();
             final boolean outputEnd;
             ioSession.getLock().lock();