Skip to content

Commit 4fb6bfe

Browse files
author
zhourenjian
committed
Destroying pipe in thread to avoid managed pipe helper being blocked
1 parent 3277d5e commit 4fb6bfe

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

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

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,29 @@ public void run() {
5757
continue; //
5858
}
5959
for (Iterator<SimplePipeRunnable> itr = pipes.iterator(); itr.hasNext();) {
60-
SimplePipeRunnable pipe = itr.next();
60+
final SimplePipeRunnable pipe = itr.next();
6161
try {
6262
if (!pipe.isPipeLive()) {
6363
if (System.currentTimeMillis() - pipe.lastLiveDetected > pipe.pipeWaitClosingInterval()) {
64-
try {
65-
pipe.pipeDestroy();
66-
} catch (Throwable e) {
67-
e.printStackTrace();
68-
}
69-
try {
70-
if (pipe.closer != null) {
71-
pipe.closer.helpClosing(pipe);
72-
} else {
73-
pipe.pipeClosed();
74-
}
75-
} catch (Throwable e) {
76-
e.printStackTrace();
77-
}
64+
(new Thread("Destroy Pipe Thread") {
65+
@Override
66+
public void run() {
67+
try {
68+
pipe.pipeDestroy();
69+
} catch (Throwable e) {
70+
e.printStackTrace();
71+
}
72+
try {
73+
if (pipe.closer != null) {
74+
pipe.closer.helpClosing(pipe);
75+
} else {
76+
pipe.pipeClosed();
77+
}
78+
} catch (Throwable e) {
79+
e.printStackTrace();
80+
}
81+
}
82+
}).start();
7883
synchronized (pipeSessions) {
7984
pipeSessions.remove(pipe.pipeKey);
8085
}

0 commit comments

Comments
 (0)