From 39503ac6d96453b67d45b746200aa83ad5c546e4 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 26 Aug 2020 16:27:59 +0200 Subject: [PATCH] Cleaned up fragment-limit for poll, added comments --- src/dorkbox/network/Server.kt | 5 ++++- src/dorkbox/network/connection/Connection.kt | 4 +++- src/dorkbox/network/handshake/ClientHandshake.kt | 8 ++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/dorkbox/network/Server.kt b/src/dorkbox/network/Server.kt index 27900f80..996cbae1 100644 --- a/src/dorkbox/network/Server.kt +++ b/src/dorkbox/network/Server.kt @@ -229,8 +229,11 @@ open class Server(config: ServerConfiguration = ServerC while (!isShutdown()) { pollCount = 0 + // NOTE: regarding fragment limit size. Repeated calls to '.poll' will reassemble a fragment. + // `.poll(handler, 4)` == `.poll(handler, 2)` + `.poll(handler, 2)` + // this checks to see if there are NEW clients on the handshake ports - pollCount += handshakeSubscription.poll(handshakeHandler, 4) + pollCount += handshakeSubscription.poll(handshakeHandler, 2) // this checks to see if there are NEW clients via IPC // pollCount += ipcHandshakeSubscription.poll(ipcInitialConnectionHandler, 100) diff --git a/src/dorkbox/network/connection/Connection.kt b/src/dorkbox/network/connection/Connection.kt index 5999973d..52a1de1f 100644 --- a/src/dorkbox/network/connection/Connection.kt +++ b/src/dorkbox/network/connection/Connection.kt @@ -191,7 +191,9 @@ open class Connection(connectionParameters: ConnectionParams<*>) { * Polls the AERON media driver subscription channel for incoming messages */ internal fun pollSubscriptions(): Int { - return subscription.poll(messageHandler, 4) + // NOTE: regarding fragment limit size. Repeated calls to '.poll' will reassemble a fragment. + // `.poll(handler, 4)` == `.poll(handler, 2)` + `.poll(handler, 2)` + return subscription.poll(messageHandler, 2) } /** diff --git a/src/dorkbox/network/handshake/ClientHandshake.kt b/src/dorkbox/network/handshake/ClientHandshake.kt index 1568a546..f541d1cb 100644 --- a/src/dorkbox/network/handshake/ClientHandshake.kt +++ b/src/dorkbox/network/handshake/ClientHandshake.kt @@ -123,7 +123,9 @@ internal class ClientHandshake(private val logger: KLogg val startTime = System.currentTimeMillis() while (System.currentTimeMillis() - startTime < connectionTimeoutMS) { - pollCount = subscription.poll(handler, 1024) + // NOTE: regarding fragment limit size. Repeated calls to '.poll' will reassemble a fragment. + // `.poll(handler, 4)` == `.poll(handler, 2)` + `.poll(handler, 2)` + pollCount = subscription.poll(handler, 2) if (failed != null) { // no longer necessary to hold this connection open @@ -165,7 +167,9 @@ internal class ClientHandshake(private val logger: KLogg val startTime = System.currentTimeMillis() while (System.currentTimeMillis() - startTime < connectionTimeoutMS) { - pollCount = subscription.poll(handler, 1024) + // NOTE: regarding fragment limit size. Repeated calls to '.poll' will reassemble a fragment. + // `.poll(handler, 4)` == `.poll(handler, 2)` + `.poll(handler, 2)` + pollCount = subscription.poll(handler, 2) if (failed != null) { // no longer necessary to hold this connection open