File tree 4 files changed +19
-4
lines changed
4 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -910,10 +910,11 @@ void Environment::InitializeLibuv() {
910
910
StartProfilerIdleNotifier ();
911
911
}
912
912
913
- void Environment::ExitEnv () {
913
+ void Environment::ExitEnv (StopFlags::Flags flags ) {
914
914
// Should not access non-thread-safe methods here.
915
915
set_stopping (true );
916
- isolate_->TerminateExecution ();
916
+ if ((flags & StopFlags::kDoNotTerminateIsolate ) == 0 )
917
+ isolate_->TerminateExecution ();
917
918
SetImmediateThreadsafe ([](Environment* env) {
918
919
env->set_can_call_into_js (false );
919
920
uv_stop (env->event_loop ());
Original file line number Diff line number Diff line change @@ -636,7 +636,7 @@ class Environment : public MemoryRetainer {
636
636
void RegisterHandleCleanups ();
637
637
void CleanupHandles ();
638
638
void Exit (ExitCode code);
639
- void ExitEnv ();
639
+ void ExitEnv (StopFlags::Flags flags );
640
640
641
641
// Register clean-up cb to be called on environment destruction.
642
642
inline void RegisterHandleCleanup (uv_handle_t * handle,
Original file line number Diff line number Diff line change @@ -1248,7 +1248,11 @@ int Start(int argc, char** argv) {
1248
1248
}
1249
1249
1250
1250
int Stop (Environment* env) {
1251
- env->ExitEnv ();
1251
+ return Stop (env, StopFlags::kNoFlags );
1252
+ }
1253
+
1254
+ int Stop (Environment* env, StopFlags::Flags flags) {
1255
+ env->ExitEnv (flags);
1252
1256
return 0 ;
1253
1257
}
1254
1258
Original file line number Diff line number Diff line change @@ -276,6 +276,15 @@ enum Flags : uint64_t {
276
276
// TODO(addaleax): Make this the canonical name, as it is more descriptive.
277
277
namespace ProcessInitializationFlags = ProcessFlags;
278
278
279
+ namespace StopFlags {
280
+ enum Flags : uint32_t {
281
+ kNoFlags = 0 ,
282
+ // Do not explicitly terminate the Isolate
283
+ // when exiting the Environment.
284
+ kDoNotTerminateIsolate = 1 << 0 ,
285
+ };
286
+ } // namespace StopFlags
287
+
279
288
class NODE_EXTERN InitializationResult {
280
289
public:
281
290
virtual ~InitializationResult ();
@@ -312,6 +321,7 @@ NODE_EXTERN int Start(int argc, char* argv[]);
312
321
// Tear down Node.js while it is running (there are active handles
313
322
// in the loop and / or actively executing JavaScript code).
314
323
NODE_EXTERN int Stop (Environment* env);
324
+ NODE_EXTERN int Stop (Environment* env, StopFlags::Flags flags);
315
325
316
326
// Set up per-process state needed to run Node.js. This will consume arguments
317
327
// from argv, fill exec_argv, and possibly add errors resulting from parsing
You can’t perform that action at this time.
0 commit comments