Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit451a1f0

Browse files
author
zhourenjian
committed
Add simple.pipe.max.items.per.query init-param in pipe's web.xml, so we can control the data stream to avoid data flood to browser and make the browser freezing.
1 parent7d7a068 commit451a1f0

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

‎sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/CompoundPipeRunnable.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public boolean isPipeLive() {
9090

9191
@Override
9292
publicvoidpipeClosed() {
93+
super.pipeClosed();
9394
for (inti =0;i <pipes.length;i++) {
9495
if (pipes[i] !=null) {
9596
if (pipes[i].closer !=null) {
@@ -104,6 +105,7 @@ public void pipeClosed() {
104105

105106
@Override
106107
publicvoidpipeLost() {
108+
super.pipeLost();
107109
for (inti =0;i <pipes.length;i++) {
108110
if (pipes[i] !=null) {
109111
pipes[i].pipeLost();

‎sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/SimplePipeHttpServlet.java‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public class SimplePipeHttpServlet extends HttpServlet {
3434

3535
protectedlongpipeScriptBreakout =1200000;// 20 minutes
3636

37+
protectedintpipeMaxItemsPerQuery = -1;// infinite
38+
3739
/*
3840
* Example of web.xml:
3941
<servlet>
@@ -47,6 +49,10 @@ public class SimplePipeHttpServlet extends HttpServlet {
4749
<param-name>simple.pipe.script.breakout</param-name>
4850
<param-value>1200000</param-value>
4951
</init-param>
52+
<init-param>
53+
<param-name>simple.pipe.max.items.per.query</param-name>
54+
<param-value>60</param-value>
55+
</init-param>
5056
</servlet>
5157
<servlet-mapping>
5258
<servlet-name>simplepipe</servlet-name>
@@ -83,6 +89,19 @@ public void init() throws ServletException {
8389
e.printStackTrace();
8490
}
8591
}
92+
StringperQueryStr =getInitParameter("simple.pipe.max.items.per.query");
93+
if (perQueryStr !=null) {
94+
try {
95+
pipeMaxItemsPerQuery =Integer.parseInt(perQueryStr);
96+
if (pipeMaxItemsPerQuery <=0 ) {
97+
pipeMaxItemsPerQuery = -1;// 0, -1 means infinite items
98+
}elseif (pipeMaxItemsPerQuery <5) {
99+
pipeMaxItemsPerQuery =5;// hey, we think limiting for less than 5 items make no senses.
100+
}
101+
}catch (NumberFormatExceptione) {
102+
e.printStackTrace();
103+
}
104+
}
86105
super.init();
87106
}
88107

@@ -193,6 +212,7 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
193212
if (pipe !=null) {
194213
waitClosingInterval =pipe.pipeWaitClosingInterval();
195214
}
215+
intitems =0;
196216
while ((vector =SimplePipeHelper.getPipeVector(key)) !=null
197217
/* && SimplePipeHelper.isPipeLive(key) */// check it!
198218
&& !writer.checkError()) {
@@ -224,6 +244,11 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
224244
}
225245
if (ss ==null)break;// terminating signal
226246
output(writer,type,key,ss.serialize());
247+
items++;
248+
if (pipeMaxItemsPerQuery >0 &&items >=pipeMaxItemsPerQuery
249+
&& !SimplePipeRequest.PIPE_TYPE_CONTINUUM.equals(type)) {
250+
break;
251+
}
227252
lastPipeDataWritten =newDate().getTime();
228253
writer.flush();
229254
if (ssinstanceofISimplePipePriority) {
@@ -256,6 +281,8 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
256281

257282
now =newDate().getTime();
258283
if ((vector =SimplePipeHelper.getPipeVector(key)) !=null// may be broken down already!!
284+
&& (pipeMaxItemsPerQuery <=0 ||items <pipeMaxItemsPerQuery
285+
||SimplePipeRequest.PIPE_TYPE_CONTINUUM.equals(type))
259286
&& (SimplePipeRequest.PIPE_TYPE_CONTINUUM.equals(type)
260287
|| (SimplePipeRequest.PIPE_TYPE_SCRIPT.equals(type)
261288
&&now -beforeLoop <pipeScriptBreakout)

‎sources/net.sf.j2s.ajax/ajaxrpc/net/sf/j2s/ajax/SimpleRPCHttpServlet.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ public boolean ignoreDefaultFields() {
142142
<param-name>simple.rpc.xss.max.parts</param-name>
143143
<param-value>10</param-value>
144144
</init-param>
145+
<init-param>
146+
<param-name>simple.rpc.xss.max.latency</param-name>
147+
<param-value>6000</param-value>
148+
</init-param>
145149
<init-param>
146150
<param-name>simple.pipe.managable</param-name>
147151
<param-value>true</param-value>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp