Net10 upgrade and threading fixes#19
Open
wjlafrance wants to merge 10 commits intoBNETDocs:developfrom
Open
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Socket.UseOnlyOverlappedIO was removed in .NET 5+. Overlapped I/O is the default behavior for async socket operations on modern .NET. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Friend.Sync() locked source then target. If two users interacted simultaneously with swapped source/target, ABBA deadlock occurred. Fix by always locking the object with the lower identity hash first. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ProcessReceive() locked on ReceiveBuffer (a byte[]) then reassigned it inside the lock. Subsequent calls locked on a different object, breaking mutual exclusion entirely. Replace with a dedicated readonly _receiveLock object used consistently for all buffer access. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ActiveGameAds was a List<GameAd> accessed from multiple threads with inconsistent locking. Add a dedicated ActiveGameAdsLock object and use it at all access sites. SID_STOPADV previously had no lock at all. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Designate() wrote to the dictionary without a lock while RemoveUser() locked it, creating a data race. Add matching lock. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ActiveChannel, ActiveClan, ActiveAccount, and GameAd could be set to null by another thread between the null check and the method call. Use local variable capture to prevent NullReferenceException. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The existing exception handling in SocketIOCompleted already catches all exceptions from message handlers and disconnects the client, so the server does not crash on malformed packets. However, the log output was unhelpful (e.g. "ArgumentOutOfRangeException error encountered!" with no packet context). Add try/catch in Invoke() that logs the message ID, size, and hex dump before disconnecting. Fix BinaryReader.ReadByteString() to throw a descriptive GameProtocolViolationException on missing null terminators instead of an opaque ArgumentOutOfRangeException. Fix GetNextNull() to restore stream position on failure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Local variable captures only prevented NullReferenceException but not the logical race (double cleanup if two threads call Close concurrently). Use lock(this) to make the entire teardown atomic. This is safe because Channel.RemoveUser already locks on the GameState (reentrant), and no other code path holds a different lock before calling Close. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
No description provided.