tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1727294 - /tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
Date Thu, 28 Jan 2016 09:44:00 GMT
Author: markt
Date: Thu Jan 28 09:44:00 2016
New Revision: 1727294

URL: http://svn.apache.org/viewvc?rev=1727294&view=rev
Log:
Reduce scope of sync blocks

Modified:
    tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java

Modified: tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java?rev=1727294&r1=1727293&r2=1727294&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Http2UpgradeHandler.java Thu Jan 28 09:44:00
2016
@@ -456,12 +456,12 @@ public class Http2UpgradeHandler extends
 
         prepareHeaders(coyoteResponse);
 
+        byte[] header = new byte[9];
+        ByteBuffer target = ByteBuffer.allocate(payloadSize);
+        boolean first = true;
+        State state = null;
         // This ensures the Stream processing thread has control of the socket.
         synchronized (socketWrapper) {
-            byte[] header = new byte[9];
-            ByteBuffer target = ByteBuffer.allocate(payloadSize);
-            boolean first = true;
-            State state = null;
             while (state != State.COMPLETE) {
                 state = getHpackEncoder().encode(coyoteResponse.getMimeHeaders(), target);
                 target.flip();
@@ -573,18 +573,18 @@ public class Http2UpgradeHandler extends
             log.debug(sm.getString("upgradeHandler.writeBody", connectionId, stream.getIdentifier(),
                     Integer.toString(len)));
         }
-        synchronized (socketWrapper) {
-            byte[] header = new byte[9];
-            ByteUtil.setThreeBytes(header, 0, len);
-            header[3] = FrameType.DATA.getIdByte();
-            if (finished) {
-                header[4] = FLAG_END_OF_STREAM;
-                stream.sentEndOfStream();
-                if (!stream.isActive()) {
-                    activeRemoteStreamCount.decrementAndGet();
-                }
+        byte[] header = new byte[9];
+        ByteUtil.setThreeBytes(header, 0, len);
+        header[3] = FrameType.DATA.getIdByte();
+        if (finished) {
+            header[4] = FLAG_END_OF_STREAM;
+            stream.sentEndOfStream();
+            if (!stream.isActive()) {
+                activeRemoteStreamCount.decrementAndGet();
             }
-            ByteUtil.set31Bits(header, 5, stream.getIdentifier().intValue());
+        }
+        ByteUtil.set31Bits(header, 5, stream.getIdentifier().intValue());
+        synchronized (socketWrapper) {
             try {
                 socketWrapper.write(true, header, 0, header.length);
                 socketWrapper.write(true, data.array(), data.arrayOffset() + data.position(),



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message