Repository navigation
Conversation
added 2 commits
October 18, 2026 23:10
When a client disconnects, its socket can be disposed while output is still queued for the session. Send() caught the ObjectDisposedException, logged a warning and returned, so the session never reached LoggedOff and ProcessDisconnects() never freed its channel. Every later queued write logged the same warning again, and the user saw "already logged in" when reconnecting. Call CloseSocket() instead, which moves the session to LoggedOff so the channel is reclaimed on the next ProcessDisconnects() pass. It is guarded by _socketClosed, so repeated calls are harmless.
Channels take the lowest free number and are freed in any order, so the channel numbers in use can have gaps (for example 0 and 2, with nothing on 1). RemoveSessions() looped i from 0 to Count - 1 and treated i as a channel number, so a channel numbered Count or higher was never checked. A logged-off session on channel 2 with only two sessions open was skipped on every pass, leaving the channel occupied and causing "already logged in" on reconnect. Loop over the channel numbers actually in use instead, still removing the highest first.
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.
When a client disconnects, its socket can be disposed while output is
still queued for the session. Send() caught the ObjectDisposedException,
logged a warning and returned, so the session never reached LoggedOff
and ProcessDisconnects() never freed its channel. Every later queued
write logged the same warning again, and the user saw "already logged
in" when reconnecting.
Call CloseSocket() instead, which moves the session to LoggedOff so the
channel is reclaimed on the next ProcessDisconnects() pass. It is
guarded by _socketClosed, so repeated calls are harmless.
Channels take the lowest free number and are freed in any order, so the
channel numbers in use can have gaps (for example 0 and 2, with nothing
on 1). RemoveSessions() looped i from 0 to Count - 1 and treated i as a
channel number, so a channel numbered Count or higher was never checked.
A logged-off session on channel 2 with only two sessions open was
skipped on every pass, leaving the channel occupied and causing "already
logged in" on reconnect.
Loop over the channel numbers actually in use instead, still removing
the highest first.