Repository navigation
Conversation
This branch has not been deployed
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.
Problem
On TShock 6.x / Terraria 1.4.5, servers randomly stop accepting players: clients hang on "Connecting to IP:port" while the console keeps working normally. Only a restart fixes it.
Two issues in
NetHooks.OnConnectionAccepted:Netplay.TcpListener.StopListening()is called. Terraria 1.4.4 restarted the listener from the server loop once a slot freed up, but 1.4.5 removed that code path (vanilla 1.4.5 never stops listening; it kicks withCLI.ServerIsFullinstead). Result: once the server is full a single time, the port is closed until restart, even after everyone leaves.FindNextOpenClientSlotonly checks!IsConnected(). A slot whose previous socket is already closed but which is stillIsActive/PendingTerminationis handed to the new client, andUpdateConnectedClientsthen callsReset()on it, dropping the new connection. This is why quick reconnects often fail.Seems like Pryaxis/TShock#3321
Fix
CLI.ServerIsFullmessage throughNetplay.KickClient(same lock as vanilla), close that socket, and keep listening.Pairs with Pryaxis/TShock#3325 (LinuxTcpSocket dead-client detection), which frees the slots that would otherwise keep the server full.