Skip to content

Commit 32a29b6

Browse files
author
zhourenjian
committed
Fixing bug that Simple Pipe may be broken on "maximized query items" break
1 parent 275cfd1 commit 32a29b6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ public void keepPipeLive() {
131131
}
132132
}
133133

134+
@Override
135+
protected void updateStatus(boolean live) {
136+
for (int i = 0; i < pipes.length; i++) {
137+
if (pipes[i] != null) {
138+
pipes[i].updateStatus(live);
139+
}
140+
}
141+
super.updateStatus(live);
142+
}
143+
134144
public boolean weave(CompoundPipeSession pipe) {
135145
pipe.pipeReset();
136146
synchronized (pipes) {

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
209209

210210
long lastPipeDataWritten = -1;
211211
long beforeLoop = System.currentTimeMillis();
212+
int items = 0;
212213
if (SimplePipeHelper.notifyPipeStatus(key, true)) { // update it!
213214
List<SimpleSerializable> list = null;
214215
int priority = 0;
@@ -218,7 +219,6 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
218219
if (pipe != null) {
219220
waitClosingInterval = pipe.pipeWaitClosingInterval();
220221
}
221-
int items = 0;
222222
while ((list = SimplePipeHelper.getPipeDataList(key)) != null
223223
/* && SimplePipeHelper.isPipeLive(key) */ // check it!
224224
&& !writer.checkError()) {
@@ -279,7 +279,8 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
279279
if ((lastPipeDataWritten == -1 && now - beforeLoop >= pipeQueryTimeout)
280280
|| (lastPipeDataWritten > 0
281281
&& now - lastPipeDataWritten >= pipeQueryTimeout
282-
&& SimplePipeRequest.PIPE_TYPE_CONTINUUM.equals(type))) {
282+
&& (SimplePipeRequest.PIPE_TYPE_CONTINUUM.equals(type)
283+
|| SimplePipeRequest.PIPE_TYPE_SCRIPT.equals(type)))) {
283284
output(writer, type, key, SimplePipeRequest.PIPE_STATUS_OK);
284285
lastPipeDataWritten = System.currentTimeMillis();
285286
}
@@ -316,7 +317,8 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
316317
// HTTP connection may be closed already!
317318
}
318319
} else if (SimplePipeRequest.PIPE_TYPE_SCRIPT.equals(type)
319-
&& System.currentTimeMillis() - beforeLoop >= pipeScriptBreakout) {
320+
&& (System.currentTimeMillis() - beforeLoop >= pipeScriptBreakout
321+
|| (pipeMaxItemsPerQuery > 0 && items >= pipeMaxItemsPerQuery))) {
320322
try {
321323
output(writer, type, key, SimplePipeRequest.PIPE_STATUS_CONTINUE);
322324
lastPipeDataWritten = System.currentTimeMillis();

0 commit comments

Comments
 (0)