Skip to content

Commit

Permalink
jsp speed fix
Browse files Browse the repository at this point in the history
`buf.clear();` 会重置缓冲区的主要索引值,不必为了每次读写都创建新的缓冲区;如果在下次写入之前不这么做,那么下次写入总是失败的。这将导致while循环总是只执行一次,数据只能513字节长度的传输,降低效率。
  • Loading branch information
XinRoom committed May 26, 2021
1 parent e5d47fa commit e56e524
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions templates/tunnel.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit e56e524

Please sign in to comment.