refactor session creation
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
parent
0d890dc1c1
commit
2f3587ef6d
|
@ -103,9 +103,12 @@ public class ClientQuicConnection extends QuicConnection
|
|||
}
|
||||
|
||||
@Override
|
||||
protected QuicSession createSession(InetSocketAddress remoteAddress, ByteBuffer cipherBuffer)
|
||||
protected QuicSession createSession(InetSocketAddress remoteAddress, ByteBuffer cipherBuffer) throws IOException
|
||||
{
|
||||
return pendingSessions.get(remoteAddress);
|
||||
QuicSession session = pendingSessions.get(remoteAddress);
|
||||
if (session != null)
|
||||
session.process(remoteAddress, cipherBuffer);
|
||||
return session;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -118,26 +118,18 @@ public abstract class QuicConnection extends AbstractConnection
|
|||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("packet contains connection ID {}", quicheConnectionId);
|
||||
|
||||
boolean created = false;
|
||||
QuicSession session = sessions.get(quicheConnectionId);
|
||||
if (session == null)
|
||||
{
|
||||
session = createSession(remoteAddress, cipherBuffer);
|
||||
if (session == null)
|
||||
continue;
|
||||
created = true;
|
||||
if (session != null && promoteSession(quicheConnectionId, session))
|
||||
sessions.put(quicheConnectionId, session);
|
||||
continue;
|
||||
}
|
||||
|
||||
// createSession() may have consumed the cipherBuffer
|
||||
if (cipherBuffer.hasRemaining())
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("packet is for existing session with connection ID {}, processing it ({} byte(s))", quicheConnectionId, cipherBuffer.remaining());
|
||||
session.process(remoteAddress, cipherBuffer);
|
||||
}
|
||||
|
||||
if (created && promoteSession(quicheConnectionId, session))
|
||||
sessions.put(quicheConnectionId, session);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("packet is for existing session with connection ID {}, processing it ({} byte(s))", quicheConnectionId, cipherBuffer.remaining());
|
||||
session.process(remoteAddress, cipherBuffer);
|
||||
}
|
||||
}
|
||||
catch (Throwable x)
|
||||
|
|
|
@ -147,7 +147,7 @@ public abstract class QuicSession
|
|||
this.quicheConnectionId = quicheConnectionId;
|
||||
}
|
||||
|
||||
void process(InetSocketAddress remoteAddress, ByteBuffer cipherBufferIn) throws IOException
|
||||
public void process(InetSocketAddress remoteAddress, ByteBuffer cipherBufferIn) throws IOException
|
||||
{
|
||||
this.remoteAddress = remoteAddress;
|
||||
quicheConnection.feedCipherText(cipherBufferIn);
|
||||
|
|
Loading…
Reference in New Issue