Skip to content

Commit 636add2

Browse files
committed
req_wrap: share process_symbol, domain_symbol
Share persistent strings process_symbol and domain_symbol across compilation units. Avoids redefinition errors when src/node.cc includes src/req_wrap.h.
1 parent a3908f4 commit 636add2

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/node.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
#include "node.h"
23+
#include "handle_wrap.h" // HandleWrap::GetActiveHandles()
2324

2425
#include "uv.h"
2526

@@ -90,6 +91,9 @@ extern char **environ;
9091

9192
namespace node {
9293

94+
// declared in req_wrap.h
95+
Persistent<String> process_symbol;
96+
Persistent<String> domain_symbol;
9397

9498
static Persistent<Object> process;
9599

@@ -106,7 +110,6 @@ static Persistent<String> listeners_symbol;
106110
static Persistent<String> uncaught_exception_symbol;
107111
static Persistent<String> emit_symbol;
108112

109-
static Persistent<String> domain_symbol;
110113
static Persistent<String> enter_symbol;
111114
static Persistent<String> exit_symbol;
112115
static Persistent<String> disposed_symbol;
@@ -1019,8 +1022,7 @@ MakeCallback(const Handle<Object> object,
10191022

10201023
TryCatch try_catch;
10211024

1022-
if (domain_symbol.IsEmpty()) {
1023-
domain_symbol = NODE_PSYMBOL("domain");
1025+
if (enter_symbol.IsEmpty()) {
10241026
enter_symbol = NODE_PSYMBOL("enter");
10251027
exit_symbol = NODE_PSYMBOL("exit");
10261028
disposed_symbol = NODE_PSYMBOL("_disposed");
@@ -2866,6 +2868,9 @@ int Start(int argc, char *argv[]) {
28662868
Persistent<Context> context = Context::New();
28672869
Context::Scope context_scope(context);
28682870

2871+
process_symbol = NODE_PSYMBOL("process");
2872+
domain_symbol = NODE_PSYMBOL("domain");
2873+
28692874
// Use original argv, as we're just copying values out of it.
28702875
Handle<Object> process_l = SetupProcessObject(argc, argv);
28712876
v8_typed_array::AttachBindings(context->Global());

src/req_wrap.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424

2525
namespace node {
2626

27-
static v8::Persistent<v8::String> process_symbol;
28-
static v8::Persistent<v8::String> domain_symbol;
27+
// defined in node.cc
28+
extern v8::Persistent<v8::String> process_symbol;
29+
extern v8::Persistent<v8::String> domain_symbol;
2930

3031
template <typename T>
3132
class ReqWrap {
@@ -34,12 +35,6 @@ class ReqWrap {
3435
v8::HandleScope scope;
3536
object_ = v8::Persistent<v8::Object>::New(v8::Object::New());
3637

37-
// TODO: grab a handle to the current process.domain
38-
if (process_symbol.IsEmpty()) {
39-
process_symbol = NODE_PSYMBOL("process");
40-
domain_symbol = NODE_PSYMBOL("domain");
41-
}
42-
4338
v8::Local<v8::Value> domain = v8::Context::GetCurrent()
4439
->Global()
4540
->Get(process_symbol)

0 commit comments

Comments
 (0)