Send close datagram when entering closing state

This commit is contained in:
Mark Spanbroek 2020-12-21 14:38:20 +01:00 committed by markspanbroek
parent a837f4f87d
commit f9da860c9d
2 changed files with 11 additions and 4 deletions

View File

@ -14,9 +14,16 @@ proc newClosingConnection*(finalDatagram: Datagram, ids: seq[ConnectionId],
state.init(ids, duration)
state
{.push locks: "unknown".}
method receive(state: ClosingConnection, datagram: Datagram) =
proc sendFinalDatagram(state: ClosingConnection) =
state.connection.outgoing.putNoWait(state.finalDatagram)
{.push locks: "unknown".}
method enter(state: ClosingConnection, connection: QuicConnection) =
procCall enter(DrainingConnection(state), connection)
state.sendFinalDatagram()
method receive(state: ClosingConnection, datagram: Datagram) =
state.sendFinalDatagram()
{.pop.}

View File

@ -32,7 +32,7 @@ proc onTimeout(state: DrainingConnection) =
{.push locks: "unknown".}
method enter(state: DrainingConnection, connection: QuicConnection) =
method enter*(state: DrainingConnection, connection: QuicConnection) =
state.connection = connection
state.timeout = newTimeout(proc = state.onTimeout())
state.timeout.set(state.duration)