From e56e52468a0103ef8ca5348be94b192ac8aeb8b5 Mon Sep 17 00:00:00 2001 From: XinRoom <32238570+XinRoom@users.noreply.github.com> Date: Thu, 27 May 2021 00:06:58 +0800 Subject: [PATCH 1/3] jsp speed fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `buf.clear();` 会重置缓冲区的主要索引值,不必为了每次读写都创建新的缓冲区;如果在下次写入之前不这么做,那么下次写入总是失败的。这将导致while循环总是只执行一次,数据只能513字节长度的传输,降低效率。 --- templates/tunnel.jsp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/tunnel.jsp b/templates/tunnel.jsp index 39512ce..d3ed6b7 100644 --- a/templates/tunnel.jsp +++ b/templates/tunnel.jsp @@ -218,6 +218,8 @@ byte[] data = new byte[bytesRead]; System.arraycopy(buf.array(), 0, data, 0, bytesRead); out.write(b64en(data)); + out.flush(); + buf.clear(); bytesRead = socketChannel.read(buf); } response.setHeader("X-STATUS", "OK"); From f52bfc0fde0913725350556836a019572c951817 Mon Sep 17 00:00:00 2001 From: XinRoom <32238570+XinRoom@users.noreply.github.com> Date: Thu, 27 May 2021 10:43:02 +0800 Subject: [PATCH 2/3] Fix error when compiled jdk9 and run with jdk8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复当使用jdk9编译的class运行于jdk8时buf.clear()错误的问题 https://github.com/plasma-umass/doppio/issues/497 --- templates/tunnel.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/tunnel.jsp b/templates/tunnel.jsp index d3ed6b7..fc96ca9 100644 --- a/templates/tunnel.jsp +++ b/templates/tunnel.jsp @@ -219,7 +219,7 @@ System.arraycopy(buf.array(), 0, data, 0, bytesRead); out.write(b64en(data)); out.flush(); - buf.clear(); + ((java.nio.Buffer)buf).clear(); bytesRead = socketChannel.read(buf); } response.setHeader("X-STATUS", "OK"); From 15d11eb56691f07d14844f44e5d54e489d9d0f67 Mon Sep 17 00:00:00 2001 From: XinRoom <32238570+XinRoom@users.noreply.github.com> Date: Thu, 27 May 2021 11:03:57 +0800 Subject: [PATCH 3/3] jspx speed bug fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 见jsp speed bug fix: https://github.com/L-codes/Neo-reGeorg/pull/40 --- templates/tunnel.jspx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/tunnel.jspx b/templates/tunnel.jspx index de936a2..ceb42c8 100644 --- a/templates/tunnel.jspx +++ b/templates/tunnel.jspx @@ -218,6 +218,8 @@ byte[] data = new byte[bytesRead]; System.arraycopy(buf.array(), 0, data, 0, bytesRead); out.write(b64en(data)); + out.flush(); + ((java.nio.Buffer)buf).clear(); bytesRead = socketChannel.read(buf); } response.setHeader("X-STATUS", "OK");