This repository has been archived by the owner on Feb 3, 2023. It is now read-only.
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.
PR summary
Add
Sim2h::get_or_create_space()
instead ofexpect()
ing it to be there.Fixes this panic: https://gist.github.com/lucksus/0abe24e4397d6f100fd8f64df0f7f093
..which can happen if the last node in a space leaves just when a message associated with that space gets processed.
testing/benchmarking notes
( if any manual testing or benchmarking was/should be done, add notes and/or screenshots here )
followups
The code was assuming to be run in a single thread which would have made these assertions be always true (checking the space is the first thing that is done with incoming messages and any function that gets called to process the message assumes its space to exist). With @neonphog's new websocket implementation we got multi-threaded and the space could have been dropped while our thread is still processing it an. Rust helps a lot in pin-pointing code that would have problems with multiple threads - nevertheless, we should take a look at the sim2h server code again if the assumption of a single thread is still baked in somehow.
For instance: could dropping the space while a thread is processing a message lead to gossip failiures?
If so: should we (read-)lock the space when a thread enters so that it does not get dropped?
I would leave these as follow-ups so we can get this fix in quickly as it makes sim2h instances crash sometimes.
changelog
documentation