| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cd233e3 commit db7deb6
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 | |
|---|---|---|---|
@@ -162,31 +162,6 @@ bool v8_is_profiling = false; | |||
| 162 | 162 | struct V8Platform v8_platform; | |
| 163 | 163 | } // namespace per_process | |
| 164 | 164 | ||
| 165 | - #ifdef __POSIX__ | ||
| 166 | - static const unsigned kMaxSignal = 32; | ||
| 167 | - #endif | ||
| 168 | - | ||
| 169 | - void WaitForInspectorDisconnect(Environment* env) { | ||
| 170 | - #if HAVE_INSPECTOR | ||
| 171 | - | ||
| 172 | - if (env->inspector_agent()->IsActive()) { | ||
| 173 | - // Restore signal dispositions, the app is done and is no longer | ||
| 174 | - // capable of handling signals. | ||
| 175 | - #if defined(__POSIX__) && !defined(NODE_SHARED_MODE) | ||
| 176 | - struct sigaction act; | ||
| 177 | - memset(&act, 0, sizeof(act)); | ||
| 178 | - for (unsigned nr = 1; nr < kMaxSignal; nr += 1) { | ||
| 179 | - if (nr == SIGKILL || nr == SIGSTOP || nr == SIGPROF) | ||
| 180 | - continue; | ||
| 181 | - act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL; | ||
| 182 | - CHECK_EQ(0, sigaction(nr, &act, nullptr)); | ||
| 183 | - } | ||
| 184 | - #endif | ||
| 185 | - env->inspector_agent()->WaitForDisconnect(); | ||
| 186 | - } | ||
| 187 | - #endif | ||
| 188 | - } | ||
| 189 | - | ||
| 190 | 165 | #ifdef __POSIX__ | |
| 191 | 166 | void SignalExit(int signo, siginfo_t* info, void* ucontext) { | |
| 192 | 167 | ResetStdio(); | |
@@ -553,6 +528,7 @@ inline void PlatformInit() { | |||
| 553 | 528 | CHECK_EQ(err, 0); | |
| 554 | 529 | #endif // HAVE_INSPECTOR | |
| 555 | 530 | ||
| 531 | + // TODO(addaleax): NODE_SHARED_MODE does not really make sense here. | ||
| 556 | 532 | #ifndef NODE_SHARED_MODE | |
| 557 | 533 | // Restore signal dispositions, the parent process may have changed them. | |
| 558 | 534 | 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 | #ifdef __POSIX__ | |
| 96 | 95 | void SignalExit(int signal, siginfo_t* info, void* ucontext); | |
@@ -321,6 +320,10 @@ void StartProfilers(Environment* env); | |||
| 321 | 320 | } | |
| 322 | 321 | #endif // HAVE_INSPECTOR | |
| 323 | 322 | ||
| 323 | + #ifdef __POSIX__ | ||
| 324 | + static constexpr unsigned kMaxSignal = 32; | ||
| 325 | + #endif | ||
| 326 | + | ||
| 324 | 327 | bool HasSignalJSHandler(int signum); | |
| 325 | 328 | ||
| 326 | 329 | #ifdef _WIN32 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -152,13 +152,26 @@ int NodeMainInstance::Run() { | |||
| 152 | 152 | ||
| 153 | 153 | env->set_trace_sync_io(false); | |
| 154 | 154 | exit_code = EmitExit(env.get()); | |
| 155 | - WaitForInspectorDisconnect(env.get()); | ||
| 156 | 155 | } | |
| 157 | 156 | ||
| 158 | 157 | env->set_can_call_into_js(false); | |
| 159 | 158 | env->stop_sub_worker_contexts(); | |
| 160 | 159 | ResetStdio(); | |
| 161 | 160 | env->RunCleanup(); | |
| 161 | + | ||
| 162 | + // TODO(addaleax): Neither NODE_SHARED_MODE nor HAVE_INSPECTOR really | ||
| 163 | + // make sense here. | ||
| 164 | + #if HAVE_INSPECTOR && 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 | + | ||
| 162 | 175 | RunAtExit(env.get()); | |
| 163 | 176 | ||
| 164 | 177 | per_process::v8_platform.DrainVMTasks(isolate_); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -433,7 +433,6 @@ static void DebugEnd(const FunctionCallbackInfo<Value>& args) { | |||
| 433 | 433 | static void ReallyExit(const FunctionCallbackInfo<Value>& args) { | |
| 434 | 434 | Environment* env = Environment::GetCurrent(args); | |
| 435 | 435 | RunAtExit(env); | |
| 436 | - WaitForInspectorDisconnect(env); | ||
| 437 | 436 | int code = args[0]->Int32Value(env->context()).FromMaybe(0); | |
| 438 | 437 | env->Exit(code); | |
| 439 | 438 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,17 +42,6 @@ using v8::Value; | |||
| 42 | 42 | namespace node { | |
| 43 | 43 | namespace worker { | |
| 44 | 44 | ||
| 45 | - namespace { | ||
| 46 | - | ||
| 47 | - #if HAVE_INSPECTOR | ||
| 48 | - void WaitForWorkerInspectorToStop(Environment* child) { | ||
| 49 | - child->inspector_agent()->WaitForDisconnect(); | ||
| 50 | - child->inspector_agent()->Stop(); | ||
| 51 | - } | ||
| 52 | - #endif | ||
| 53 | - | ||
| 54 | - } // anonymous namespace | ||
| 55 | - | ||
| 56 | 45 | Worker::Worker(Environment* env, | |
| 57 | 46 | Local<Object> wrap, | |
| 58 | 47 | const std::string& url, | |
@@ -251,9 +240,6 @@ void Worker::Run() { | |||
| 251 | 240 | Locker locker(isolate_); | |
| 252 | 241 | Isolate::Scope isolate_scope(isolate_); | |
| 253 | 242 | SealHandleScope outer_seal(isolate_); | |
| 254 | - #if HAVE_INSPECTOR | ||
| 255 | - bool inspector_started = false; | ||
| 256 | - #endif | ||
| 257 | 243 | ||
| 258 | 244 | DeleteFnPtr<Environment, FreeEnvironment> env_; | |
| 259 | 245 | OnScopeLeave cleanup_env([&]() { | |
@@ -283,10 +269,6 @@ void Worker::Run() { | |||
| 283 | 269 | env_->stop_sub_worker_contexts(); | |
| 284 | 270 | env_->RunCleanup(); | |
| 285 | 271 | RunAtExit(env_.get()); | |
| 286 | - #if HAVE_INSPECTOR | ||
| 287 | - if (inspector_started) | ||
| 288 | - WaitForWorkerInspectorToStop(env_.get()); | ||
| 289 | - #endif | ||
| 290 | 272 | ||
| 291 | 273 | // This call needs to be made while the `Environment` is still alive | |
| 292 | 274 | // because we assume that it is available for async tracking in the | |
@@ -344,7 +326,6 @@ void Worker::Run() { | |||
| 344 | 326 | env_->InitializeDiagnostics(); | |
| 345 | 327 | #if HAVE_INSPECTOR | |
| 346 | 328 | env_->InitializeInspector(inspector_parent_handle_.release()); | |
| 347 | - inspector_started = true; | ||
| 348 | 329 | #endif | |
| 349 | 330 | HandleScope handle_scope(isolate_); | |
| 350 | 331 | InternalCallbackScope callback_scope( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments