mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-08 08:10:55 +03:00
Ignore socket timeout in read which occurs if we have set the timeout to > 0. We should continue reading from the stream unless the reader is interrupted. Note that with the default timeout set to 0, the reader thread will never return.
This commit is contained in:
@@ -40,6 +40,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.SocketTimeoutException;
|
||||
|
||||
public final class Reader
|
||||
extends Thread {
|
||||
@@ -65,13 +66,21 @@ public final class Reader
|
||||
int needed = 1;
|
||||
|
||||
while (!isInterrupted()) {
|
||||
int read = inp.read(recvbuf, 0, needed);
|
||||
int read;
|
||||
try {
|
||||
read = inp.read(recvbuf, 0, needed);
|
||||
}
|
||||
catch(SocketTimeoutException e) {
|
||||
if (isInterrupted()) {
|
||||
throw e;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (read == -1)
|
||||
throw new TransportException("Broken transport; encountered EOF");
|
||||
else
|
||||
needed = decoder.received(recvbuf, read);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
if (isInterrupted()) {
|
||||
// We are meant to shut up and draw to a close if interrupted
|
||||
|
||||
Reference in New Issue
Block a user