Issue #1146 - jetty.server.HttpInput deadlock.

Moved calls to close(Throwable) outside synchronized blocks, since
they mail fail callbacks that reenter into caller code, causing
deadlocks.
This commit is contained in:
Simone Bordet 2016-12-20 10:39:36 +01:00
parent 3b73265331
commit 753aa5ca37
1 changed files with 349 additions and 340 deletions

View File

@ -509,7 +509,11 @@ public class SslConnection extends AbstractConnection
}
@Override
public synchronized int fill(ByteBuffer buffer) throws IOException
public int fill(ByteBuffer buffer) throws IOException
{
try
{
synchronized (this)
{
try
{
@ -702,7 +706,6 @@ public class SslConnection extends AbstractConnection
catch (SSLHandshakeException x)
{
notifyHandshakeFailed(_sslEngine, x);
close(x);
throw x;
}
catch (SSLException x)
@ -712,12 +715,6 @@ public class SslConnection extends AbstractConnection
x = (SSLException)new SSLHandshakeException(x.getMessage()).initCause(x);
notifyHandshakeFailed(_sslEngine, x);
}
close(x);
throw x;
}
catch (Throwable x)
{
close(x);
throw x;
}
finally
@ -741,6 +738,13 @@ public class SslConnection extends AbstractConnection
}
}
}
}
catch (Throwable x)
{
close(x);
throw x;
}
}
private void closeInbound()
{
@ -755,7 +759,7 @@ public class SslConnection extends AbstractConnection
}
@Override
public synchronized boolean flush(ByteBuffer... appOuts) throws IOException
public boolean flush(ByteBuffer... appOuts) throws IOException
{
// The contract for flush does not require that all appOuts bytes are written
// or even that any appOut bytes are written! If the connection is write block
@ -770,6 +774,10 @@ public class SslConnection extends AbstractConnection
LOG.debug("{} flush {}", SslConnection.this, BufferUtil.toHexSummary(b));
}
try
{
synchronized (this)
{
try
{
if (_cannotAcceptMoreAppDataToFlush)
@ -913,12 +921,6 @@ public class SslConnection extends AbstractConnection
catch (SSLHandshakeException x)
{
notifyHandshakeFailed(_sslEngine, x);
close(x);
throw x;
}
catch (Throwable x)
{
close(x);
throw x;
}
finally
@ -926,6 +928,13 @@ public class SslConnection extends AbstractConnection
releaseEncryptedOutputBuffer();
}
}
}
catch (Throwable x)
{
close(x);
throw x;
}
}
private void releaseEncryptedOutputBuffer()
{