Skip to content

Commit

Permalink
src: clear envinst_ after env
Browse files Browse the repository at this point in the history
As long as env() doesn't return nullptr it is assumed that access to
envinst_ is possible. So change the order of cleanup.

PR-URL: #24
Reviewed-by: Santiago Gimeno <[email protected]>
  • Loading branch information
trevnorris committed Nov 13, 2023
1 parent 1dca94b commit 3ec83cd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/nsolid/nsolid_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -973,9 +973,6 @@ void EnvList::RemoveEnv(Environment* env) {
envinst_sp->env()->isolate()->RemoveGCEpilogueCallback(
EnvInst::v8_gc_epilogue_cb_, envinst_sp.get());

// Remove the instance from env
env->envinst_.reset();

// End any pending spans and notify the user.
if (env->is_main_thread()) {
tracer_.endPendingSpans();
Expand All @@ -997,6 +994,9 @@ void EnvList::RemoveEnv(Environment* env) {
// and only accessed from another thread if the env still exists and has been
// Scope locked.
envinst_sp->env_.store(nullptr, std::memory_order_relaxed);

// Remove the instance from env
env->envinst_.reset();
}


Expand Down

0 comments on commit 3ec83cd

Please sign in to comment.