Commits comibned Carl Hasselskog and Jakub Adamek patches for PTCP deadlock fix.
This commit is contained in:
parent
137de02c4f
commit
24a6f9a95d
@ -507,12 +507,15 @@ class PseudoTcpSocketImpl
|
|||||||
*/
|
*/
|
||||||
public void onTcpReadable(PseudoTCPBase tcp)
|
public void onTcpReadable(PseudoTCPBase tcp)
|
||||||
{
|
{
|
||||||
//release all thread blocked at read_notify monitor
|
if(logger.isLoggable(Level.FINER))
|
||||||
synchronized (read_notify)
|
|
||||||
{
|
{
|
||||||
logger.log(
|
logger.log(
|
||||||
Level.FINER,
|
Level.FINER,
|
||||||
"TCP READABLE data available for reading: "+tcp.getAvailable());
|
"TCP READABLE data available for reading: "+tcp.getAvailable());
|
||||||
|
}
|
||||||
|
//release all thread blocked at read_notify monitor
|
||||||
|
synchronized (read_notify)
|
||||||
|
{
|
||||||
read_notify.notifyAll();
|
read_notify.notifyAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -877,7 +880,8 @@ class PseudoTcpSocketImpl
|
|||||||
* @throws IOException in case of error or if timeout occurs
|
* @throws IOException in case of error or if timeout occurs
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int read(byte[] buffer, int offset, int length) throws IOException
|
public int read(byte[] buffer, int offset, int length)
|
||||||
|
throws IOException
|
||||||
{
|
{
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
int read;
|
int read;
|
||||||
@ -886,43 +890,53 @@ class PseudoTcpSocketImpl
|
|||||||
logger.log(Level.FINER, "Read Recv");
|
logger.log(Level.FINER, "Read Recv");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
synchronized (read_notify)
|
read = pseudoTcp.recv(buffer, offset, length);
|
||||||
|
if (logger.isLoggable(Level.FINER))
|
||||||
{
|
{
|
||||||
read = pseudoTcp.recv(buffer, offset, length);
|
logger.log(Level.FINER,
|
||||||
if (logger.isLoggable(Level.FINER))
|
"Read Recv read count: " + read);
|
||||||
|
}
|
||||||
|
if (read > 0)
|
||||||
|
{
|
||||||
|
return read;
|
||||||
|
}
|
||||||
|
logger.log(Level.FINER, "Read wait for data available");
|
||||||
|
if(readTimeout > 0)
|
||||||
|
{
|
||||||
|
//Check for timeout
|
||||||
|
long elapsed = System.currentTimeMillis() - start;
|
||||||
|
long left = readTimeout - elapsed;
|
||||||
|
if(left <= 0)
|
||||||
{
|
{
|
||||||
logger.log(Level.FINER, "Read Recv read count: " + read);
|
IOException exc =
|
||||||
|
new IOException("Read operation timeout");
|
||||||
|
pseudoTcp.closedown(exc);
|
||||||
|
throw exc;
|
||||||
}
|
}
|
||||||
if (read > 0)
|
synchronized (read_notify)
|
||||||
{
|
{
|
||||||
return read;
|
if(pseudoTcp.getAvailable() == 0)
|
||||||
}
|
|
||||||
logger.log(Level.FINER, "Read wait for data available");
|
|
||||||
if(readTimeout > 0)
|
|
||||||
{
|
|
||||||
//Check for timeout
|
|
||||||
long elapsed = System.currentTimeMillis() - start;
|
|
||||||
long left = readTimeout - elapsed;
|
|
||||||
if(left <= 0)
|
|
||||||
{
|
{
|
||||||
IOException exc =
|
read_notify.wait(left);
|
||||||
new IOException("Read operation timeout");
|
|
||||||
pseudoTcp.closedown(exc);
|
|
||||||
throw exc;
|
|
||||||
}
|
}
|
||||||
read_notify.wait(left);
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
synchronized (read_notify)
|
||||||
{
|
{
|
||||||
read_notify.wait();
|
if(pseudoTcp.getAvailable() == 0)
|
||||||
}
|
{
|
||||||
if (logger.isLoggable(Level.FINER))
|
read_notify.wait();
|
||||||
{
|
}
|
||||||
logger.log(
|
|
||||||
Level.FINER,
|
|
||||||
"Read notified: " + pseudoTcp.getAvailable());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (logger.isLoggable(Level.FINER))
|
||||||
|
{
|
||||||
|
logger.log(
|
||||||
|
Level.FINER,
|
||||||
|
"Read notified: " + pseudoTcp.getAvailable());
|
||||||
|
}
|
||||||
if (exception != null)
|
if (exception != null)
|
||||||
{
|
{
|
||||||
throw exception;
|
throw exception;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user