fix: CombatThread queue draining, per-instance Spigot404Write queues, and LagCompensator synchronization - #162
Open
GamingOP69 wants to merge 3 commits into
Conversation
… and LagCompensator synchronization
Updated comments for clarity regarding thread safety and movement registration.
Author
|
CombatThread.run() it was doing size() > 0 then poll() on a |
Author
|
Spigot404Write had its packet queue and task list as static fields, meaning |
Contributor
|
please sync this PR - LagCompensator was removed |
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
Resolves race conditions and thread safety issues in
CombatThread,Spigot404Write, andLagCompensator.Problem & Root Cause
CombatThread.run(), checkingsize() > 0before callingpoll()on aConcurrentLinkedQueueis not an atomic operation. If the queue was drained by another thread or empty between calls,poll()returnednull, resulting inNullPointerExceptionwhen calling.run(), which permanently crashed the async combat thread loop.Spigot404Writeused static packet queues and task lists across player connections, allowing packets intended for one player's channel to leak into another.LagCompensator.locationTimesused an un-synchronizedArrayListMultimapthat was accessed and iterated simultaneously from both Netty I/O threads and the main server tick thread, causing sporadicConcurrentModificationExceptioncrashes.Solution
CombatThread.run()to poll directly into a local variable and checkif (task != null) task.run().Spigot404Writepacket queues and task collections per-instance fields tied to individual connections.LagCompensator.locationTimeswithMultimaps.synchronizedListMultimapand added proper synchronized blocks around its iteration blocks.