From 80a612ea1195ad7176c4e0378ef013ab25b8b456 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Tue, 3 Nov 2020 16:45:06 +0100 Subject: [PATCH] Rename: waitForHandshake() -> handshake() --- quic/connection.nim | 2 +- quic/ngtcp2/handshake.nim | 6 ++++++ quic/ngtcp2/udp.nim | 5 ----- tests/helpers/connections.nim | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/quic/connection.nim b/quic/connection.nim index d739e87..82ac162 100644 --- a/quic/connection.nim +++ b/quic/connection.nim @@ -10,7 +10,7 @@ export newClientConnection export newServerConnection export receive, send export isHandshakeCompleted -export waitForHandshake +export handshake export Stream export openStream export close diff --git a/quic/ngtcp2/handshake.nim b/quic/ngtcp2/handshake.nim index 4a7c89e..e770dee 100644 --- a/quic/ngtcp2/handshake.nim +++ b/quic/ngtcp2/handshake.nim @@ -1,5 +1,11 @@ +import chronos import ngtcp2 import connection +import udp proc isHandshakeCompleted*(connection: Connection): bool = ngtcp2_conn_get_handshake_completed(connection.conn).bool + +proc handshake*(connection: Connection) {.async.} = + while not connection.isHandshakeCompleted: + await connection.send() diff --git a/quic/ngtcp2/udp.nim b/quic/ngtcp2/udp.nim index d7da1ff..c545f3c 100644 --- a/quic/ngtcp2/udp.nim +++ b/quic/ngtcp2/udp.nim @@ -7,7 +7,6 @@ import ../congestion import connection import path import errors -import handshake proc trySend(connection: Connection): Datagram = var packetInfo: ngtcp2_pkt_info @@ -36,10 +35,6 @@ proc send*(connection: Connection) {.async.} = datagram = connection.trySend() await connection.outgoing.put(datagram) -proc waitForHandshake*(connection: Connection) {.async.} = - while not connection.isHandshakeCompleted: - await connection.send() - proc receive*(connection: Connection, datagram: DatagramBuffer, ecn = ecnNonCapable) = var packetInfo: ngtcp2_pkt_info packetInfo.ecn = ecn.uint32 diff --git a/tests/helpers/connections.nim b/tests/helpers/connections.nim index ceb09e9..98935a4 100644 --- a/tests/helpers/connections.nim +++ b/tests/helpers/connections.nim @@ -10,13 +10,13 @@ proc sendLoop(source, destination: Connection) {.async.} = proc performHandshake*: Future[tuple[client, server: Connection]] {.async.} = let client = newClientConnection(zeroAddress, zeroAddress) - let clientHandshake = client.waitForHandshake() + let clientHandshake = client.handshake() let datagram = await client.outgoing.get() let server = newServerConnection(zeroAddress, zeroAddress, datagram.data) server.receive(datagram) - let serverHandshake = server.waitForHandshake() + let serverHandshake = server.handshake() let clientLoop = sendLoop(client, server) let serverLoop = sendLoop(server, client)