mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-07 07:40:55 +03:00
Fix local port forwarding disconnecting issue (#491)
* `SocketStreamCopyMonitor` closes channel after setting the one event. It doesn't wait for the second stream to finish the job. * #317 Fix `SocketStreamCopyMonitor` to wait for all events before closing the channel.
This commit is contained in:
committed by
Jeroen van Erp
parent
a5017d55c8
commit
0cd19284ee
@@ -39,15 +39,21 @@ public class SocketStreamCopyMonitor
|
||||
new SocketStreamCopyMonitor(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
for (Event<IOException> ev = x;
|
||||
!ev.tryAwait(frequency, unit);
|
||||
ev = (ev == x) ? y : x) {
|
||||
}
|
||||
await(x);
|
||||
await(y);
|
||||
} catch (IOException ignored) {
|
||||
} finally {
|
||||
IOUtils.closeQuietly(channel, asCloseable(socket));
|
||||
}
|
||||
}
|
||||
|
||||
private void await(final Event<IOException> event) throws IOException {
|
||||
while(true){
|
||||
if(event.tryAwait(frequency, unit)){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user