fix: network manager event loop flush, compression lookup, and shutdown order - #161
Open
GamingOP69 wants to merge 6 commits into
Open
fix: network manager event loop flush, compression lookup, and shutdown order#161GamingOP69 wants to merge 6 commits into
GamingOP69 wants to merge 6 commits into
Conversation
…rder, and lazy init concurrency
Fixed the pipeline key for the PacketCompressor to ensure proper compression handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes packet flushing thread safety in
NetworkManager, pipeline key lookup during compression setup,sendQueuedPacketserror recovery, and clean shutdown ordering inServerConnection.Problem & Root Cause
NetworkManager.flush()calledchannel.flush()directly from non-I/O threads (such as the main server tick thread). Netty channel pipelines are not thread-safe for direct off-thread pipeline manipulations, which could lead to unflushed packets sitting in channel buffers.setupCompressionlooked up the handler with key"decompress"instead of"compress", failing to insert the compression handler in the expected pipeline position.PlayerConnection.sendQueuedPackets(), if packet serialization threw an exception during queue draining,enableAutomaticFlush()would never get called, permanently stalling the connection's automatic flushing.ServerConnection.stopServer()shut down event loop groups before closing the listening channels, throwingNullPointerExceptionand resource leak warnings on server shutdown.LazyInitVarlacked double-checked locking, allowing race conditions during concurrent initialization of Netty transport groups.Solution
NetworkManager.flush()to execute flushes viachannel.eventLoop().execute(...)when called outside the I/O event loop."compress".sendQueuedPackets()draining in atry-finallyblock to guaranteeenableAutomaticFlush()runs even if an exception occurs.ServerConnection.LazyInitVarwithLazyInitVarTestconcurrency unit test.