Skip to content

Commit

Permalink
src: reset main_thread_id_ when it is removed
Browse files Browse the repository at this point in the history
When the Environment instance associated with the main thread is
removed, reset the main_thread_id_. This will make sure calls to
GetMainEnvInst() don't return something invalid.

PR-URL: #24
Reviewed-by: Santiago Gimeno <[email protected]>
  • Loading branch information
trevnorris committed Nov 13, 2023
1 parent d849d3f commit 3ac8239
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/nsolid/nsolid_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,10 @@ void EnvList::RemoveEnv(Environment* env) {
CHECK(it != env_map_.end());
CHECK_EQ(envinst_sp, it->second);
#endif
// Remove the main thread id if the main thread is being removed.
if (main_thread_id_ == env->thread_id()) {
main_thread_id_ = 0xFFFFFFFFFFFFFFFF;
}
env_map_.erase(env->thread_id());
}

Expand Down

0 comments on commit 3ac8239

Please sign in to comment.