Skip to content

Commit

Permalink
#10519 do not close the flusher to avoid an ISE when iterating it dur…
Browse files Browse the repository at this point in the history
…ing idle timeout

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban committed Oct 25, 2023
1 parent a8a8c8b commit 8b5deea
Showing 1 changed file with 9 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,25 +401,15 @@ public void outwardClose(long error, String reason)
if (LOG.isDebugEnabled())
LOG.debug("outward closing 0x{}/{} on {}", Long.toHexString(error), reason, this);
quicheConnection.close(error, reason);
try
{
// Flushing will eventually forward the outward close to the connection.
flush();
}
catch (IllegalStateException ise)
{
// Flusher already is in CLOSED state, nothing else to do.
if (LOG.isDebugEnabled())
LOG.debug("IllegalStateException caught while flushing, flusher={} {}", flusher, this, ise);
}
// Flushing will eventually forward the outward close to the connection.
flush();
}

private void finishOutwardClose(Throwable failure)
{
try
{
endPoints.clear();
flusher.close();
getQuicConnection().outwardClose(this, failure);
}
finally
Expand Down Expand Up @@ -464,13 +454,6 @@ public void onTimeoutExpired()
};
}

@Override
public void close()
{
super.close();
timeout.destroy();
}

@Override
protected Action process() throws IOException
{
Expand Down Expand Up @@ -523,17 +506,22 @@ protected void onCompleteSuccess()
{
if (LOG.isDebugEnabled())
LOG.debug("connection closed {}", QuicSession.this);
byteBufferPool.release(cipherBuffer);
finishOutwardClose(new ClosedChannelException());
finish(new ClosedChannelException());
}

@Override
protected void onCompleteFailure(Throwable failure)
{
if (LOG.isDebugEnabled())
LOG.debug("failed to write cipher bytes, closing session on {}", QuicSession.this, failure);
finish(failure);
}

private void finish(Throwable failure)
{
byteBufferPool.release(cipherBuffer);
finishOutwardClose(failure);
timeout.destroy();
}
}

Expand Down

0 comments on commit 8b5deea

Please sign in to comment.