Skip to content

Commit 3ac8239

Browse files
committed
src: reset main_thread_id_ when it is removed
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]>
1 parent d849d3f commit 3ac8239

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/nsolid/nsolid_api.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,10 @@ void EnvList::RemoveEnv(Environment* env) {
936936
CHECK(it != env_map_.end());
937937
CHECK_EQ(envinst_sp, it->second);
938938
#endif
939+
// Remove the main thread id if the main thread is being removed.
940+
if (main_thread_id_ == env->thread_id()) {
941+
main_thread_id_ = 0xFFFFFFFFFFFFFFFF;
942+
}
939943
env_map_.erase(env->thread_id());
940944
}
941945

0 commit comments

Comments
 (0)