Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Move a few more global vars into struct
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Dec 8, 2011
1 parent e10fd32 commit cced79d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/cares_wrap.cc
Expand Up @@ -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 {
Expand All @@ -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();
Expand Down
18 changes: 7 additions & 11 deletions src/node.cc
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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());

Expand Down
11 changes: 11 additions & 0 deletions src/node_vars.h
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions src/platform_openbsd.cc
Expand Up @@ -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[]) {
Expand Down

0 comments on commit cced79d

Please sign in to comment.