Remember final connection ids when draining

Fixes problem where not all connection ids were removed
from the listener, leading to datagrams being received by
a closed connection.
This commit is contained in:
Mark Spanbroek 2020-12-16 15:08:03 +01:00 committed by markspanbroek
parent a01669bc5c
commit ca06e74957
2 changed files with 6 additions and 3 deletions

View File

@ -10,14 +10,16 @@ type
DrainingConnection* = ref object of ConnectionState
connection: QuicConnection
finalDatagram: Datagram
ids: seq[ConnectionId]
timeout: Timeout
duration: Duration
done: AsyncEvent
proc newDrainingConnection*(finalDatagram: Datagram,
proc newDrainingConnection*(finalDatagram: Datagram, ids: seq[ConnectionId],
duration: Duration): DrainingConnection =
DrainingConnection(
finalDatagram: finalDatagram,
ids: ids,
duration: duration,
done: newAsyncEvent()
)
@ -35,7 +37,7 @@ method leave(state: DrainingConnection) =
state.connection = nil
method ids(state: DrainingConnection): seq[ConnectionId] =
@[]
state.ids
method send(state: DrainingConnection) =
raise newException(ClosedConnectionError, "connection is closing")

View File

@ -39,7 +39,8 @@ method openStream(state: OpenConnection): Future[Stream] {.async.} =
method drain(state: OpenConnection) {.async.} =
let finalDatagram = state.ngtcp2Connection.close()
let duration = state.ngtcp2Connection.closingDuration()
let draining = newDrainingConnection(finalDatagram, duration)
let ids = state.ids
let draining = newDrainingConnection(finalDatagram, ids, duration)
state.quicConnection.switch(draining)
await draining.drain()