From 685468fd70e220b9ec40f12e5ec300830d62517c Mon Sep 17 00:00:00 2001 From: "Ray J. Greenwell" Date: Thu, 23 Oct 2025 11:10:28 -0700 Subject: [PATCH] ConnectionManager can be configured to allow larger messages. Messages that are too big are dropped and the clients have no hope of recovering. Warnings are logged but that's it. Allow bigger. --- .../threerings/nio/conman/ConnectionManager.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/threerings/nio/conman/ConnectionManager.java b/core/src/main/java/com/threerings/nio/conman/ConnectionManager.java index 751a33e5a..171eb656e 100644 --- a/core/src/main/java/com/threerings/nio/conman/ConnectionManager.java +++ b/core/src/main/java/com/threerings/nio/conman/ConnectionManager.java @@ -66,6 +66,16 @@ public abstract class ConnectionManager extends LoopingThread _onExit = onExit; } + /** + * Set the largest number of bytes we'll send in a message. + * Messages larger than this will log, refuse to send, and then things go badly for that client. + * We don't presently handle this well, we may as well disconnect the player at that point. + */ + public void setMaximumMessageSize (int maximumMessageSize) + { + _maxMsgSize = maximumMessageSize; + } + /** * Returns our current runtime statistics. Note: don't call this method too * frequently as it is synchronized and will contend with the network I/O thread. @@ -339,7 +349,7 @@ public abstract class ConnectionManager extends LoopingThread } // sanity check the message size - if (data.length > 1024 * 1024) { + if (data.length > _maxMsgSize) { log.warning("Refusing to write very large message", "conn", conn, "size", data.length); return true; } @@ -606,6 +616,9 @@ public abstract class ConnectionManager extends LoopingThread /** Our current runtime stats. */ protected ConMgrStats _stats = new ConMgrStats(); + /** The maximum message size we'll send. */ + protected int _maxMsgSize = 1024 * 1024; + /** Used to periodically report connection manager activity when in debug mode. */ protected long _lastDebugStamp;