mirror of https://github.com/vacp2p/nim-quic.git
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:
parent
a01669bc5c
commit
ca06e74957
|
@ -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")
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue