diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-12-08 15:09:47 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-12-08 15:09:47 -0800 |
commit | cced79d4a840f1b8f0b044657aac033e0596cb03 (patch) | |
tree | 12d80700e380fc092ca9a0125f36c35f38c49cf3 | |
parent | e10fd321e44804b98f77d2eaedb9b47e7635fb41 (diff) | |
download | node-new-cced79d4a840f1b8f0b044657aac033e0596cb03.tar.gz |
Move a few more global vars into struct
-rw-r--r-- | src/cares_wrap.cc | 10 | ||||
-rw-r--r-- | src/node.cc | 18 | ||||
-rw-r--r-- | src/node_vars.h | 11 | ||||
-rw-r--r-- | src/platform_openbsd.cc | 6 |
4 files changed, 27 insertions, 18 deletions
diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index a881c25b07..89ae4581da 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -48,6 +48,11 @@ #endif +#include <node_vars.h> +#define oncomplete_sym NODE_VAR(oncomplete_sym) +#define ares_channel NODE_VAR(ares_channel) + + namespace node { namespace cares_wrap { @@ -69,11 +74,6 @@ using v8::Value; typedef class ReqWrap<uv_getaddrinfo_t> GetAddrInfoReqWrap; -static Persistent<String> oncomplete_sym; - -static ares_channel ares_channel; - - static Local<Array> HostentToAddresses(struct hostent* host) { HandleScope scope; Local<Array> addresses = Array::New(); diff --git a/src/node.cc b/src/node.cc index 7a58277ec5..11b6fa7709 100644 --- a/src/node.cc +++ b/src/node.cc @@ -131,6 +131,12 @@ extern char **environ; #define use_debug_agent NODE_VAR(use_debug_agent) #define use_npn NODE_VAR(use_npn) #define use_sni NODE_VAR(use_sni) +#define uncaught_exception_counter NODE_VAR(uncaught_exception_counter) +#define debug_watcher NODE_VAR(debug_watcher) +#define binding_cache NODE_VAR(binding_cache) +#define module_load_list NODE_VAR(module_load_list) +#define node_isolate NODE_VAR(node_isolate) +#define debugger_running NODE_VAR(debugger_running) namespace node { @@ -1685,7 +1691,6 @@ static void OnFatalError(const char* location, const char* message) { exit(1); } -static int uncaught_exception_counter = 0; void FatalException(TryCatch &try_catch) { HandleScope scope; @@ -1738,8 +1743,6 @@ void FatalException(TryCatch &try_catch) { } -static uv_async_t debug_watcher; - static void DebugMessageCallback(uv_async_t* watcher, int status) { HandleScope scope; assert(watcher == &debug_watcher); @@ -1762,9 +1765,6 @@ static void DebugBreakMessageHandler(const Debug::Message& message) { } -Persistent<Object> binding_cache; -Persistent<Array> module_load_list; - static Handle<Value> Binding(const Arguments& args) { HandleScope scope; @@ -2256,9 +2256,6 @@ static void ParseArgs(int argc, char **argv) { } -static Isolate* node_isolate = NULL; -static volatile bool debugger_running = false; - static void EnableDebug(bool wait_connect) { // If we're called from another thread, make sure to enter the right // v8 isolate. @@ -2561,8 +2558,7 @@ char** Init(int argc, char *argv[]) { // main thread to execute a random bit of javascript - which will give V8 // control so it can handle whatever new message had been received on the // debug thread. - uv_async_init(uv_default_loop(), &node::debug_watcher, - node::DebugMessageCallback); + uv_async_init(uv_default_loop(), &debug_watcher, node::DebugMessageCallback); // unref it so that we exit the event loop despite it being active. uv_unref(uv_default_loop()); diff --git a/src/node_vars.h b/src/node_vars.h index d6caac100b..3f0ec391f5 100644 --- a/src/node_vars.h +++ b/src/node_vars.h @@ -64,6 +64,14 @@ struct globals { # define RPM_SAMPLES 100 int64_t tick_times[RPM_SAMPLES]; int tick_time_head; + int uncaught_exception_counter; + uv_async_t debug_watcher; + v8::Persistent<v8::Object> binding_cache; + v8::Persistent<v8::Array> module_load_list; + v8::Isolate* node_isolate; + volatile bool debugger_running; + + // stream_wrap.cc size_t slab_used; @@ -179,6 +187,9 @@ struct globals { // node_signal_watcher.cc v8::Persistent<v8::String> callback_symbol; v8::Persistent<v8::FunctionTemplate> signal_watcher_constructor_template; + + // cares_wrap.cc + ::ares_channel ares_channel; }; struct globals* globals_get(); diff --git a/src/platform_openbsd.cc b/src/platform_openbsd.cc index 9399ad7acd..ce140bb7b5 100644 --- a/src/platform_openbsd.cc +++ b/src/platform_openbsd.cc @@ -36,13 +36,15 @@ #include <fcntl.h> #include <unistd.h> #include <time.h> - #include <stdio.h> + +#include <node_vars.h> +#define process_title NODE_VAR(process_title) + namespace node { using namespace v8; -static char *process_title; double Platform::prog_start_time = Platform::GetUptime(); char** Platform::SetupArgs(int argc, char *argv[]) { |