Skip to content

Commit

Permalink
Adding timeouts to wait methods, to never allow for infinite thread w…
Browse files Browse the repository at this point in the history
…ait.
  • Loading branch information
Experrior committed Aug 19, 2024
1 parent 15dfef3 commit aeb667c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/com/trilead/ssh2/StreamGobbler.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public int read() throws IOException

try
{
synchronizer.wait();
synchronizer.wait(30*60*1000);
}
catch (InterruptedException e)
{
Expand Down Expand Up @@ -210,7 +210,7 @@ public int read(byte[] b, int off, int len) throws IOException

try
{
synchronizer.wait();
synchronizer.wait(30*60*1000);
}
catch (InterruptedException e)
{
Expand Down
4 changes: 2 additions & 2 deletions src/com/trilead/ssh2/channel/ChannelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public void sendData(Channel c, byte[] buffer, int pos, int len) throws IOExcept

try
{
c.wait();
c.wait(30*60*1000);
}
catch (InterruptedException ignore)
{
Expand Down Expand Up @@ -913,7 +913,7 @@ public int waitForCondition(Channel c, long timeout, int condition_mask) throws
if (timeout > 0)
c.wait(timeout);
else
c.wait();
c.wait(30*60*1000);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/com/trilead/ssh2/channel/FifoBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void write(byte[] buf, int start, int len) throws InterruptedException {

synchronized (lock) {
while ((chunk = Math.min(len,writable()))==0)
lock.wait();
lock.wait(30*60*1000);

w.write(buf, start, chunk);

Expand Down Expand Up @@ -209,7 +209,7 @@ public int read(byte[] buf, int start, int len) throws InterruptedException {
releaseRing();
return -1; // no more data
}
lock.wait(); // wait until the writer gives us something
lock.wait(12*60*60*1000); // wait until the writer gives us something
}

r.read(buf,start,chunk);
Expand Down
2 changes: 1 addition & 1 deletion src/com/trilead/ssh2/transport/KexManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public ConnectionInfo getOrWaitForConnectionInfo(int minKexCount) throws IOExcep

try
{
accessLock.wait();
accessLock.wait(30*60*1000);
}
catch (InterruptedException e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/com/trilead/ssh2/transport/TransportManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ public void sendMessage(byte[] msg) throws IOException

try
{
connectionSemaphore.wait();
connectionSemaphore.wait(30*60*1000);
}
catch (InterruptedException e)
{
Expand Down

0 comments on commit aeb667c

Please sign in to comment.