Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions MBBSEmu/HostProcess/MbbsHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,12 @@ private void RemoveSessions(Predicate<SessionBase> match)
// _channelDictionary
Stack<ushort> channelsToRemove = new Stack<ushort>();

for (ushort i = 0; i < _channelDictionary.Count; i++)
//Channel keys can be sparse (0, 2 with nothing at 1), so iterate the keys rather than 0..Count
foreach (var channel in _channelDictionary.Keys
.Where(k => match(_channelDictionary[k]))
.OrderBy(k => k))
{
//Because users might not be on sequential channels (0,1,3), we verify if the channel number
//is even in use first.
if (!_channelDictionary.ContainsKey(i) || !match(_channelDictionary[i])) continue;

channelsToRemove.Push(i);
channelsToRemove.Push((ushort)channel);
}

while (channelsToRemove.Count > 0)
Expand Down
4 changes: 3 additions & 1 deletion MBBSEmu/Session/SocketSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public virtual void Send(byte[] dataToSend)
}
catch (ObjectDisposedException)
{
_logger.Warn($"Channel {Channel}: Attempted to write on a disposed socket");
//Closing moves the session to LoggedOff so the host reclaims the channel
_logger.Warn($"Channel {Channel}: write on a disposed socket -- closing session");
CloseSocket("write on disposed socket");
}
catch (Exception ex)
{
Expand Down