| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d14d9e8 commit fc9e708
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -778,6 +778,13 @@ bool Agent::Start(const std::string& path, | |||
| 778 | 778 | StartDebugSignalHandler(); | |
| 779 | 779 | } | |
| 780 | 780 | ||
| 781 | + AtExit(parent_env_, [](void* env) { | ||
| 782 | + Agent* agent = static_cast<Environment*>(env)->inspector_agent(); | ||
| 783 | + if (agent->IsActive()) { | ||
| 784 | + agent->WaitForDisconnect(); | ||
| 785 | + } | ||
| 786 | + }, parent_env_); | ||
| 787 | + | ||
| 781 | 788 | bool wait_for_connect = options.wait_for_connect(); | |
| 782 | 789 | if (parent_handle_) { | |
| 783 | 790 | wait_for_connect = parent_handle_->WaitForConnect(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -151,31 +151,6 @@ bool v8_is_profiling = false; | |||
| 151 | 151 | struct V8Platform v8_platform; | |
| 152 | 152 | } // namespace per_process | |
| 153 | 153 | ||
| 154 | - #ifdef __POSIX__ | ||
| 155 | - static const unsigned kMaxSignal = 32; | ||
| 156 | - #endif | ||
| 157 | - | ||
| 158 | - void WaitForInspectorDisconnect(Environment* env) { | ||
| 159 | - #if HAVE_INSPECTOR | ||
| 160 | - | ||
| 161 | - if (env->inspector_agent()->IsActive()) { | ||
| 162 | - // Restore signal dispositions, the app is done and is no longer | ||
| 163 | - // capable of handling signals. | ||
| 164 | - #if defined(__POSIX__) && !defined(NODE_SHARED_MODE) | ||
| 165 | - struct sigaction act; | ||
| 166 | - memset(&act, 0, sizeof(act)); | ||
| 167 | - for (unsigned nr = 1; nr < kMaxSignal; nr += 1) { | ||
| 168 | - if (nr == SIGKILL || nr == SIGSTOP || nr == SIGPROF) | ||
| 169 | - continue; | ||
| 170 | - act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL; | ||
| 171 | - CHECK_EQ(0, sigaction(nr, &act, nullptr)); | ||
| 172 | - } | ||
| 173 | - #endif | ||
| 174 | - env->inspector_agent()->WaitForDisconnect(); | ||
| 175 | - } | ||
| 176 | - #endif | ||
| 177 | - } | ||
| 178 | - | ||
| 179 | 154 | void SignalExit(int signo) { | |
| 180 | 155 | ResetStdio(); | |
| 181 | 156 | #ifdef __FreeBSD__ | |
@@ -522,6 +497,7 @@ inline void PlatformInit() { | |||
| 522 | 497 | CHECK_EQ(err, 0); | |
| 523 | 498 | #endif // HAVE_INSPECTOR | |
| 524 | 499 | ||
| 500 | + // TODO(addaleax): NODE_SHARED_MODE does not really make sense here. | ||
| 525 | 501 | #ifndef NODE_SHARED_MODE | |
| 526 | 502 | // Restore signal dispositions, the parent process may have changed them. | |
| 527 | 503 | struct sigaction act; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -90,7 +90,6 @@ void PrintCaughtException(v8::Isolate* isolate, | |||
| 90 | 90 | v8::Local<v8::Context> context, | |
| 91 | 91 | const v8::TryCatch& try_catch); | |
| 92 | 92 | ||
| 93 | - void WaitForInspectorDisconnect(Environment* env); | ||
| 94 | 93 | void ResetStdio(); // Safe to call more than once and from signal handlers. | |
| 95 | 94 | void SignalExit(int signo); | |
| 96 | 95 | #ifdef __POSIX__ | |
@@ -313,6 +312,10 @@ void StartProfilers(Environment* env); | |||
| 313 | 312 | } | |
| 314 | 313 | #endif // HAVE_INSPECTOR | |
| 315 | 314 | ||
| 315 | + #ifdef __POSIX__ | ||
| 316 | + static constexpr unsigned kMaxSignal = 32; | ||
| 317 | + #endif | ||
| 318 | + | ||
| 316 | 319 | bool HasSignalJSHandler(int signum); | |
| 317 | 320 | ||
| 318 | 321 | #ifdef _WIN32 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -145,13 +145,26 @@ int NodeMainInstance::Run() { | |||
| 145 | 145 | ||
| 146 | 146 | env->set_trace_sync_io(false); | |
| 147 | 147 | exit_code = EmitExit(env.get()); | |
| 148 | - WaitForInspectorDisconnect(env.get()); | ||
| 149 | 148 | } | |
| 150 | 149 | ||
| 151 | 150 | env->set_can_call_into_js(false); | |
| 152 | 151 | env->stop_sub_worker_contexts(); | |
| 153 | 152 | ResetStdio(); | |
| 154 | 153 | env->RunCleanup(); | |
| 154 | + | ||
| 155 | + // TODO(addaleax): Neither NODE_SHARED_MODE nor HAVE_INSPECTOR really | ||
| 156 | + // make sense here. | ||
| 157 | + #if HAVE_INSPECTOR && defined(__POSIX__) && !defined(NODE_SHARED_MODE) | ||
| 158 | + struct sigaction act; | ||
| 159 | + memset(&act, 0, sizeof(act)); | ||
| 160 | + for (unsigned nr = 1; nr < kMaxSignal; nr += 1) { | ||
| 161 | + if (nr == SIGKILL || nr == SIGSTOP || nr == SIGPROF) | ||
| 162 | + continue; | ||
| 163 | + act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL; | ||
| 164 | + CHECK_EQ(0, sigaction(nr, &act, nullptr)); | ||
| 165 | + } | ||
| 166 | + #endif | ||
| 167 | + | ||
| 155 | 168 | RunAtExit(env.get()); | |
| 156 | 169 | ||
| 157 | 170 | per_process::v8_platform.DrainVMTasks(isolate_); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -426,7 +426,6 @@ static void DebugEnd(const FunctionCallbackInfo<Value>& args) { | |||
| 426 | 426 | static void ReallyExit(const FunctionCallbackInfo<Value>& args) { | |
| 427 | 427 | Environment* env = Environment::GetCurrent(args); | |
| 428 | 428 | RunAtExit(env); | |
| 429 | - WaitForInspectorDisconnect(env); | ||
| 430 | 429 | int code = args[0]->Int32Value(env->context()).FromMaybe(0); | |
| 431 | 430 | env->Exit(code); | |
| 432 | 431 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,17 +37,6 @@ using v8::Value; | |||
| 37 | 37 | namespace node { | |
| 38 | 38 | namespace worker { | |
| 39 | 39 | ||
| 40 | - namespace { | ||
| 41 | - | ||
| 42 | - #if HAVE_INSPECTOR | ||
| 43 | - void WaitForWorkerInspectorToStop(Environment* child) { | ||
| 44 | - child->inspector_agent()->WaitForDisconnect(); | ||
| 45 | - child->inspector_agent()->Stop(); | ||
| 46 | - } | ||
| 47 | - #endif | ||
| 48 | - | ||
| 49 | - } // anonymous namespace | ||
| 50 | - | ||
| 51 | 40 | Worker::Worker(Environment* env, | |
| 52 | 41 | Local<Object> wrap, | |
| 53 | 42 | const std::string& url, | |
@@ -191,9 +180,6 @@ void Worker::Run() { | |||
| 191 | 180 | Locker locker(isolate_); | |
| 192 | 181 | Isolate::Scope isolate_scope(isolate_); | |
| 193 | 182 | SealHandleScope outer_seal(isolate_); | |
| 194 | - #if HAVE_INSPECTOR | ||
| 195 | - bool inspector_started = false; | ||
| 196 | - #endif | ||
| 197 | 183 | ||
| 198 | 184 | DeleteFnPtr<Environment, FreeEnvironment> env_; | |
| 199 | 185 | OnScopeLeave cleanup_env([&]() { | |
@@ -223,10 +209,6 @@ void Worker::Run() { | |||
| 223 | 209 | env_->stop_sub_worker_contexts(); | |
| 224 | 210 | env_->RunCleanup(); | |
| 225 | 211 | RunAtExit(env_.get()); | |
| 226 | - #if HAVE_INSPECTOR | ||
| 227 | - if (inspector_started) | ||
| 228 | - WaitForWorkerInspectorToStop(env_.get()); | ||
| 229 | - #endif | ||
| 230 | 212 | ||
| 231 | 213 | // This call needs to be made while the `Environment` is still alive | |
| 232 | 214 | // because we assume that it is available for async tracking in the | |
@@ -270,7 +252,6 @@ void Worker::Run() { | |||
| 270 | 252 | env_->InitializeDiagnostics(); | |
| 271 | 253 | #if HAVE_INSPECTOR | |
| 272 | 254 | env_->InitializeInspector(inspector_parent_handle_.release()); | |
| 273 | - inspector_started = true; | ||
| 274 | 255 | #endif | |
| 275 | 256 | HandleScope handle_scope(isolate_); | |
| 276 | 257 | AsyncCallbackScope callback_scope(env_.get()); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments