Skip to content

Commit

Permalink
src: move DebugPortGetter/Setter to node_process.cc
Browse files Browse the repository at this point in the history
PR-URL: #22758
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
  • Loading branch information
jasnell authored and targos committed Sep 19, 2018
1 parent e268b64 commit 415eac8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 27 deletions.
27 changes: 0 additions & 27 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ using v8::Object;
using v8::ObjectTemplate;
using v8::Promise;
using v8::PropertyAttribute;
using v8::PropertyCallbackInfo;
using v8::ReadOnly;
using v8::Script;
using v8::ScriptCompiler;
Expand Down Expand Up @@ -1733,32 +1732,6 @@ static Local<Object> GetFeatures(Environment* env) {
return scope.Escape(obj);
}


static void DebugPortGetter(Local<Name> property,
const PropertyCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
Mutex::ScopedLock lock(process_mutex);
int port = env->options()->debug_options->port();
#if HAVE_INSPECTOR
if (port == 0) {
if (auto io = env->inspector_agent()->io())
port = io->port();
}
#endif // HAVE_INSPECTOR
info.GetReturnValue().Set(port);
}


static void DebugPortSetter(Local<Name> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info) {
Environment* env = Environment::GetCurrent(info);
Mutex::ScopedLock lock(process_mutex);
env->options()->debug_options->host_port.port =
value->Int32Value(env->context()).FromMaybe(0);
}


static void DebugProcess(const FunctionCallbackInfo<Value>& args);
static void DebugEnd(const FunctionCallbackInfo<Value>& args);

Expand Down
5 changes: 5 additions & 0 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,11 @@ void EnvSetter(v8::Local<v8::Name> property,
void EnvQuery(v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Integer>& info);
void EnvEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info);
void DebugPortGetter(v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Value>& info);
void DebugPortSetter(v8::Local<v8::Name> property,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<void>& info);

void GetParentProcessId(v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Value>& info);
Expand Down
29 changes: 29 additions & 0 deletions src/node_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include "uv.h"
#include "v8.h"

#if HAVE_INSPECTOR
#include "inspector_io.h"
#endif

#include <limits.h> // PATH_MAX
#include <stdio.h>

Expand Down Expand Up @@ -833,4 +837,29 @@ void GetActiveHandles(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(ary);
}

void DebugPortGetter(Local<Name> property,
const PropertyCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
Mutex::ScopedLock lock(process_mutex);
int port = env->options()->debug_options->port();
#if HAVE_INSPECTOR
if (port == 0) {
if (auto io = env->inspector_agent()->io())
port = io->port();
}
#endif // HAVE_INSPECTOR
info.GetReturnValue().Set(port);
}


void DebugPortSetter(Local<Name> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info) {
Environment* env = Environment::GetCurrent(info);
Mutex::ScopedLock lock(process_mutex);
env->options()->debug_options->host_port.port =
value->Int32Value(env->context()).FromMaybe(0);
}


} // namespace node

0 comments on commit 415eac8

Please sign in to comment.