fix: dedicated server thread safety, disconnect deadlock, and console freeze
- Protect PlayerList and ServerConnection players vectors with critical sections; all iterations use copy-on-read snapshots to prevent iterator invalidation during concurrent join/leave - Add null check on player bounding box in movement validation to prevent crash when player is removed mid-tick - Re-validate socket player pointer immediately before SendData to narrow the TOCTOU race window on disconnect - Replace inline disconnect cleanup with a queued system drained on the main tick thread, eliminating the done_cs -> m_playersCS lock inversion that caused deadlocks under load - Disable Windows QuickEdit mode at server startup to prevent console input selection from freezing the process - Move chunk priority sort behind ServerConnection::sortPlayersByChunkPriority() to keep the players vector lock-protected
This commit is contained in:
@@ -20,6 +20,7 @@ private:
|
||||
int connectionCounter;
|
||||
private:
|
||||
CRITICAL_SECTION pending_cs; // 4J added
|
||||
CRITICAL_SECTION players_cs; // Protects players vector for concurrent access
|
||||
vector< shared_ptr<PendingConnection> > pending;
|
||||
vector< shared_ptr<PlayerConnection> > players;
|
||||
|
||||
@@ -47,4 +48,6 @@ public:
|
||||
void handleTextureAndGeometryReceived(const wstring &textureName);
|
||||
void handleServerSettingsChanged(shared_ptr<ServerSettingsChangedPacket> packet);
|
||||
vector< shared_ptr<PlayerConnection> > *getPlayers();
|
||||
vector< shared_ptr<PlayerConnection> > getPlayersSnapshot();
|
||||
void sortPlayersByChunkPriority();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user