Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a Race Condition if a disconnect were to happen during processing… #551

Merged
merged 1 commit into from
Mar 14, 2022

Conversation

enusbaum
Copy link
Member

Fixes Discord Issue where a disconnect can trigger a race condition when trying to read the Text Variables defined on a channel during the main process loop.

mbbsemu    | 2022-03-14 15:58:50.2780 Warn MBBSEmu.Session.SocketSession.CloseSocket Session 10.80.0.152:50434 (Channel: 0) Client disconnected
mbbsemu    | 2022-03-14 15:58:50.3367 Info MBBSEmu.HostProcess.MbbsHost.RemoveSession Removing Channel: 0
mbbsemu    | Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key '0' was not present in the dictionary.
mbbsemu    |    at System.Collections.Generic.Dictionary`2.get_Item(TKey )
mbbsemu    |    at MBBSEmu.HostProcess.ExportedModules.ExportedModuleBase.ProcessTextVariables(ReadOnlySpan`1 outputBuffer)
mbbsemu    |    at MBBSEmu.HostProcess.ExportedModules.ExportedModuleBase.FormatOutput(ReadOnlySpan`1 outputBytes)
mbbsemu    |    at MBBSEmu.HostProcess.ExportedModules.Galgsbl.btuxmt()
mbbsemu    |    at MBBSEmu.HostProcess.ExportedModules.Galgsbl.Invoke(UInt16 ordinal, Boolean offsetsOnly)
mbbsemu    |    at MBBSEmu.HostProcess.ExecutionUnits.ExecutionUnit.ExternalFunctionDelegate(UInt16 ordinal, UInt16 functionOrdinal)
mbbsemu    |    at MBBSEmu.CPU.CpuCore.Op_Call()
mbbsemu    |    at MBBSEmu.CPU.CpuCore.Tick()
mbbsemu    |    at MBBSEmu.HostProcess.ExecutionUnits.ExecutionUnit.Execute(FarPtr entryPoint, UInt16 channelNumber, Boolean simulateCallFar, Boolean bypassState, Queue`1 initialStackValues, UInt16 initialStackPointer)
mbbsemu    |    at MBBSEmu.Module.MbbsModule.Execute(FarPtr entryPoint, UInt16 channelNumber, Boolean simulateCallFar, Boolean bypassSetState, Queue`1 initialStackValues, UInt16 initialStackPointer)
mbbsemu    |    at MBBSEmu.HostProcess.MbbsHost.WorkerThread()
mbbsemu    |    at System.Threading.Thread.StartCallback()

@enusbaum enusbaum requested a review from paladine March 14, 2022 20:44
@paladine paladine merged commit 227d3be into master Mar 14, 2022
@paladine paladine deleted the textvar-race branch March 14, 2022 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants