Browse Source

Add node::Loop() and don't inc node_isolate.h in *.cc

node::Loop() replaces the NODE_LOOP macro. This avoids hitting
v8::Isolate::GetCurrent() for each loop lookup when HAVE_ISOLATE==0
v0.7.4-release
Ryan Dahl 13 years ago
parent
commit
9d792f3183
  1. 10
      src/cares_wrap.cc
  2. 10
      src/fs_event_wrap.cc
  3. 4
      src/handle_wrap.cc
  4. 19
      src/node.cc
  5. 6
      src/node.h
  6. 6
      src/node_crypto.cc
  7. 8
      src/node_file.cc
  8. 4
      src/node_zlib.cc
  9. 10
      src/pipe_wrap.cc
  10. 8
      src/process_wrap.cc
  11. 16
      src/stream_wrap.cc
  12. 28
      src/tcp_wrap.cc
  13. 20
      src/timer_wrap.cc
  14. 8
      src/tty_wrap.cc
  15. 18
      src/udp_wrap.cc

10
src/cares_wrap.cc

@ -22,7 +22,7 @@
#include <assert.h> #include <assert.h>
#include <node.h> #include <node.h>
#include <req_wrap.h> #include <req_wrap.h>
#include <node_isolate.h> #include <node_vars.h>
#include <uv.h> #include <uv.h>
#include <string.h> #include <string.h>
@ -608,7 +608,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
if (status) { if (status) {
// Error // Error
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
argv[0] = Local<Value>::New(Null()); argv[0] = Local<Value>::New(Null());
} else { } else {
// Success // Success
@ -711,7 +711,7 @@ static Handle<Value> GetAddrInfo(const Arguments& args) {
hints.ai_family = fam; hints.ai_family = fam;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
int r = uv_getaddrinfo(NODE_LOOP(), int r = uv_getaddrinfo(Loop(),
&req_wrap->req_, &req_wrap->req_,
AfterGetAddrInfo, AfterGetAddrInfo,
*hostname, *hostname,
@ -720,7 +720,7 @@ static Handle<Value> GetAddrInfo(const Arguments& args) {
req_wrap->Dispatched(); req_wrap->Dispatched();
if (r) { if (r) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
delete req_wrap; delete req_wrap;
return scope.Close(v8::Null()); return scope.Close(v8::Null());
} else { } else {
@ -737,7 +737,7 @@ static void Initialize(Handle<Object> target) {
assert(r == ARES_SUCCESS); assert(r == ARES_SUCCESS);
struct ares_options options; struct ares_options options;
uv_ares_init_options(NODE_LOOP(), &ares_channel, &options, 0); uv_ares_init_options(Loop(), &ares_channel, &options, 0);
assert(r == 0); assert(r == 0);
NODE_SET_METHOD(target, "queryA", Query<QueryAWrap>); NODE_SET_METHOD(target, "queryA", Query<QueryAWrap>);

10
src/fs_event_wrap.cc

@ -21,7 +21,7 @@
#include <node.h> #include <node.h>
#include <handle_wrap.h> #include <handle_wrap.h>
#include <node_isolate.h> #include <node_vars.h>
#include <stdlib.h> #include <stdlib.h>
@ -110,15 +110,15 @@ Handle<Value> FSEventWrap::Start(const Arguments& args) {
String::Utf8Value path(args[0]->ToString()); String::Utf8Value path(args[0]->ToString());
int r = uv_fs_event_init(NODE_LOOP(), &wrap->handle_, *path, OnEvent, 0); int r = uv_fs_event_init(Loop(), &wrap->handle_, *path, OnEvent, 0);
if (r == 0) { if (r == 0) {
// Check for persistent argument // Check for persistent argument
if (!args[1]->IsTrue()) { if (!args[1]->IsTrue()) {
uv_unref(NODE_LOOP()); uv_unref(Loop());
} }
wrap->initialized_ = true; wrap->initialized_ = true;
} else { } else {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
} }
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r));
@ -146,7 +146,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
// assumption that a rename implicitly means an attribute change. Not too // assumption that a rename implicitly means an attribute change. Not too
// unreasonable, right? Still, we should revisit this before v1.0. // unreasonable, right? Still, we should revisit this before v1.0.
if (status) { if (status) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
eventStr = String::Empty(); eventStr = String::Empty();
} }
else if (events & UV_RENAME) { else if (events & UV_RENAME) {

4
src/handle_wrap.cc

@ -21,7 +21,7 @@
#include <node.h> #include <node.h>
#include <handle_wrap.h> #include <handle_wrap.h>
#include <node_isolate.h> #include <node_vars.h>
namespace node { namespace node {
@ -71,7 +71,7 @@ Handle<Value> HandleWrap::Unref(const Arguments& args) {
} }
wrap->unref = true; wrap->unref = true;
uv_unref(NODE_LOOP()); uv_unref(Loop());
return v8::Undefined(); return v8::Undefined();
} }

19
src/node.cc

@ -147,6 +147,15 @@ void StartThread(Isolate* isolate,
char** argv); char** argv);
uv_loop_t* Loop() {
#if defined(HAVE_ISOLATES) && HAVE_ISOLATES
return Isolate::GetCurrent()->GetLoop();
#else
return uv_default_loop();
#endif
}
static void StartGCTimer () { static void StartGCTimer () {
if (!uv_is_active((uv_handle_t*) &gc_timer)) { if (!uv_is_active((uv_handle_t*) &gc_timer)) {
uv_timer_start(&gc_timer, node::CheckStatus, 5000, 5000); uv_timer_start(&gc_timer, node::CheckStatus, 5000, 5000);
@ -173,7 +182,7 @@ static void Idle(uv_idle_t* watcher, int status) {
static void Check(uv_check_t* watcher, int status) { static void Check(uv_check_t* watcher, int status) {
assert(watcher == &gc_check); assert(watcher == &gc_check);
tick_times[tick_time_head] = uv_now(NODE_LOOP()); tick_times[tick_time_head] = uv_now(Loop());
tick_time_head = (tick_time_head + 1) % RPM_SAMPLES; tick_time_head = (tick_time_head + 1) % RPM_SAMPLES;
StartGCTimer(); StartGCTimer();
@ -203,7 +212,7 @@ static void Tick(void) {
need_tick_cb = false; need_tick_cb = false;
if (uv_is_active((uv_handle_t*) &tick_spinner)) { if (uv_is_active((uv_handle_t*) &tick_spinner)) {
uv_idle_stop(&tick_spinner); uv_idle_stop(&tick_spinner);
uv_unref(NODE_LOOP()); uv_unref(Loop());
} }
HandleScope scope; HandleScope scope;
@ -245,7 +254,7 @@ static Handle<Value> NeedTickCallback(const Arguments& args) {
// tick_spinner to keep the event loop alive long enough to handle it. // tick_spinner to keep the event loop alive long enough to handle it.
if (!uv_is_active((uv_handle_t*) &tick_spinner)) { if (!uv_is_active((uv_handle_t*) &tick_spinner)) {
uv_idle_start(&tick_spinner, Spin); uv_idle_start(&tick_spinner, Spin);
uv_ref(NODE_LOOP()); uv_ref(Loop());
} }
return Undefined(); return Undefined();
} }
@ -1497,7 +1506,7 @@ static void CheckStatus(uv_timer_t* watcher, int status) {
} }
} }
double d = uv_now(NODE_LOOP()) - TICK_TIME(3); double d = uv_now(Loop()) - TICK_TIME(3);
//printfb("timer d = %f\n", d); //printfb("timer d = %f\n", d);
@ -1526,7 +1535,7 @@ static Handle<Value> Uptime(const Arguments& args) {
v8::Handle<v8::Value> UVCounters(const v8::Arguments& args) { v8::Handle<v8::Value> UVCounters(const v8::Arguments& args) {
HandleScope scope; HandleScope scope;
uv_counters_t* c = &NODE_LOOP()->counters; uv_counters_t* c = &Loop()->counters;
Local<Object> obj = Object::New(); Local<Object> obj = Object::New();

6
src/node.h

@ -75,8 +75,6 @@
#define NODE_STRINGIFY_HELPER(n) #n #define NODE_STRINGIFY_HELPER(n) #n
#endif #endif
#define NODE_LOOP() (node::Isolate::GetCurrent()->GetLoop())
namespace node { namespace node {
int Start(int argc, char *argv[]); int Start(int argc, char *argv[]);
@ -86,6 +84,10 @@ v8::Handle<v8::Object> SetupProcessObject(int argc, char *argv[]);
void Load(v8::Handle<v8::Object> process); void Load(v8::Handle<v8::Object> process);
void EmitExit(v8::Handle<v8::Object> process); void EmitExit(v8::Handle<v8::Object> process);
// Returns the loop for the current isolate. If compiled with
// --without-isolates then this will always return uv_default_loop();
uv_loop_t* Loop();
#define NODE_PSYMBOL(s) \ #define NODE_PSYMBOL(s) \
v8::Persistent<v8::String>::New(v8::String::NewSymbol(s)) v8::Persistent<v8::String>::New(v8::String::NewSymbol(s))

6
src/node_crypto.cc

@ -24,7 +24,7 @@
#include <node.h> #include <node.h>
#include <node_buffer.h> #include <node_buffer.h>
#include <node_isolate.h> #include <node_vars.h>
#include <node_root_certs.h> #include <node_root_certs.h>
#include <string.h> #include <string.h>
@ -4118,7 +4118,7 @@ PBKDF2(const Arguments& args) {
req = new uv_work_t(); req = new uv_work_t();
req->data = request; req->data = request;
uv_queue_work(NODE_LOOP(), req, EIO_PBKDF2, EIO_PBKDF2After); uv_queue_work(Loop(), req, EIO_PBKDF2, EIO_PBKDF2After);
return Undefined(); return Undefined();
@ -4241,7 +4241,7 @@ Handle<Value> RandomBytes(const Arguments& args) {
Local<Function> callback_v = Local<Function>(Function::Cast(*args[1])); Local<Function> callback_v = Local<Function>(Function::Cast(*args[1]));
req->callback_ = Persistent<Function>::New(callback_v); req->callback_ = Persistent<Function>::New(callback_v);
uv_queue_work(NODE_LOOP(), uv_queue_work(Loop(),
&req->work_req_, &req->work_req_,
RandomBytesWork<generator>, RandomBytesWork<generator>,
RandomBytesAfter<generator>); RandomBytesAfter<generator>);

8
src/node_file.cc

@ -22,7 +22,7 @@
#include "node.h" #include "node.h"
#include "node_file.h" #include "node_file.h"
#include "node_buffer.h" #include "node_buffer.h"
#include <node_isolate.h> #include <node_vars.h>
#ifdef __POSIX__ #ifdef __POSIX__
# include "node_stat_watcher.h" # include "node_stat_watcher.h"
#endif #endif
@ -226,7 +226,7 @@ struct fs_req_wrap {
#define ASYNC_CALL(func, callback, ...) \ #define ASYNC_CALL(func, callback, ...) \
FSReqWrap* req_wrap = new FSReqWrap(); \ FSReqWrap* req_wrap = new FSReqWrap(); \
int r = uv_fs_##func(NODE_LOOP(), &req_wrap->req_, \ int r = uv_fs_##func(Loop(), &req_wrap->req_, \
__VA_ARGS__, After); \ __VA_ARGS__, After); \
assert(r == 0); \ assert(r == 0); \
req_wrap->object_->Set(oncomplete_sym, callback); \ req_wrap->object_->Set(oncomplete_sym, callback); \
@ -235,9 +235,9 @@ struct fs_req_wrap {
#define SYNC_CALL(func, path, ...) \ #define SYNC_CALL(func, path, ...) \
fs_req_wrap req_wrap; \ fs_req_wrap req_wrap; \
int result = uv_fs_##func(NODE_LOOP(), &req_wrap.req, __VA_ARGS__, NULL); \ int result = uv_fs_##func(Loop(), &req_wrap.req, __VA_ARGS__, NULL); \
if (result < 0) { \ if (result < 0) { \
int code = uv_last_error(NODE_LOOP()).code; \ int code = uv_last_error(Loop()).code; \
return ThrowException(UVException(code, #func, "", path)); \ return ThrowException(UVException(code, #func, "", path)); \
} }

4
src/node_zlib.cc

@ -29,7 +29,7 @@
#include <node.h> #include <node.h>
#include <node_buffer.h> #include <node_buffer.h>
#include <node_isolate.h> #include <node_vars.h>
#include <req_wrap.h> #include <req_wrap.h>
#include <node_vars.h> #include <node_vars.h>
@ -134,7 +134,7 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap {
uv_work_t* work_req = new uv_work_t(); uv_work_t* work_req = new uv_work_t();
work_req->data = req_wrap; work_req->data = req_wrap;
uv_queue_work(NODE_LOOP(), uv_queue_work(Loop(),
work_req, work_req,
ZCtx<mode>::Process, ZCtx<mode>::Process,
ZCtx<mode>::After); ZCtx<mode>::After);

10
src/pipe_wrap.cc

@ -21,7 +21,7 @@
#include <node.h> #include <node.h>
#include <node_buffer.h> #include <node_buffer.h>
#include <node_isolate.h> #include <node_vars.h>
#include <req_wrap.h> #include <req_wrap.h>
#include <handle_wrap.h> #include <handle_wrap.h>
#include <stream_wrap.h> #include <stream_wrap.h>
@ -124,7 +124,7 @@ Handle<Value> PipeWrap::New(const Arguments& args) {
PipeWrap::PipeWrap(Handle<Object> object, bool ipc) PipeWrap::PipeWrap(Handle<Object> object, bool ipc)
: StreamWrap(object, (uv_stream_t*) &handle_) { : StreamWrap(object, (uv_stream_t*) &handle_) {
int r = uv_pipe_init(NODE_LOOP(), &handle_, ipc); int r = uv_pipe_init(Loop(), &handle_, ipc);
assert(r == 0); // How do we proxy this error up to javascript? assert(r == 0); // How do we proxy this error up to javascript?
// Suggestion: uv_pipe_init() returns void. // Suggestion: uv_pipe_init() returns void.
handle_.data = reinterpret_cast<void*>(this); handle_.data = reinterpret_cast<void*>(this);
@ -142,7 +142,7 @@ Handle<Value> PipeWrap::Bind(const Arguments& args) {
int r = uv_pipe_bind(&wrap->handle_, *name); int r = uv_pipe_bind(&wrap->handle_, *name);
// Error starting the pipe. // Error starting the pipe.
if (r) SetErrno(uv_last_error(NODE_LOOP())); if (r) SetErrno(uv_last_error(Loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r));
} }
@ -173,7 +173,7 @@ Handle<Value> PipeWrap::Listen(const Arguments& args) {
int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection); int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection);
// Error starting the pipe. // Error starting the pipe.
if (r) SetErrno(uv_last_error(NODE_LOOP())); if (r) SetErrno(uv_last_error(Loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r));
} }
@ -226,7 +226,7 @@ void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
assert(wrap->object_.IsEmpty() == false); assert(wrap->object_.IsEmpty() == false);
if (status) { if (status) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
} }
Local<Value> argv[3] = { Local<Value> argv[3] = {

8
src/process_wrap.cc

@ -21,7 +21,7 @@
#include <node.h> #include <node.h>
#include <handle_wrap.h> #include <handle_wrap.h>
#include <node_isolate.h> #include <node_vars.h>
#include <pipe_wrap.h> #include <pipe_wrap.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -176,7 +176,7 @@ class ProcessWrap : public HandleWrap {
Get(String::NewSymbol("windowsVerbatimArguments"))->IsTrue(); Get(String::NewSymbol("windowsVerbatimArguments"))->IsTrue();
#endif #endif
int r = uv_spawn(NODE_LOOP(), &wrap->process_, options); int r = uv_spawn(Loop(), &wrap->process_, options);
wrap->SetHandle((uv_handle_t*)&wrap->process_); wrap->SetHandle((uv_handle_t*)&wrap->process_);
assert(wrap->process_.data == wrap); assert(wrap->process_.data == wrap);
@ -196,7 +196,7 @@ class ProcessWrap : public HandleWrap {
delete [] options.env; delete [] options.env;
} }
if (r) SetErrno(uv_last_error(NODE_LOOP())); if (r) SetErrno(uv_last_error(Loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r));
} }
@ -210,7 +210,7 @@ class ProcessWrap : public HandleWrap {
int r = uv_process_kill(&wrap->process_, signal); int r = uv_process_kill(&wrap->process_, signal);
if (r) SetErrno(uv_last_error(NODE_LOOP())); if (r) SetErrno(uv_last_error(Loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r));
} }

16
src/stream_wrap.cc

@ -21,7 +21,7 @@
#include <node.h> #include <node.h>
#include <node_buffer.h> #include <node_buffer.h>
#include <node_isolate.h> #include <node_vars.h>
#include <handle_wrap.h> #include <handle_wrap.h>
#include <stream_wrap.h> #include <stream_wrap.h>
#include <tcp_wrap.h> #include <tcp_wrap.h>
@ -133,7 +133,7 @@ Handle<Value> StreamWrap::ReadStart(const Arguments& args) {
} }
// Error starting the tcp. // Error starting the tcp.
if (r) SetErrno(uv_last_error(NODE_LOOP())); if (r) SetErrno(uv_last_error(Loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r));
} }
@ -147,7 +147,7 @@ Handle<Value> StreamWrap::ReadStop(const Arguments& args) {
int r = uv_read_stop(wrap->stream_); int r = uv_read_stop(wrap->stream_);
// Error starting the tcp. // Error starting the tcp.
if (r) SetErrno(uv_last_error(NODE_LOOP())); if (r) SetErrno(uv_last_error(Loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r));
} }
@ -226,7 +226,7 @@ void StreamWrap::OnReadCommon(uv_stream_t* handle, ssize_t nread,
slab_used -= buf.len; slab_used -= buf.len;
} }
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
MakeCallback(wrap->object_, "onread", 0, NULL); MakeCallback(wrap->object_, "onread", 0, NULL);
return; return;
} }
@ -339,7 +339,7 @@ Handle<Value> StreamWrap::Write(const Arguments& args) {
wrap->UpdateWriteQueueSize(); wrap->UpdateWriteQueueSize();
if (r) { if (r) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
delete req_wrap; delete req_wrap;
return scope.Close(v8::Null()); return scope.Close(v8::Null());
} else { } else {
@ -359,7 +359,7 @@ void StreamWrap::AfterWrite(uv_write_t* req, int status) {
assert(wrap->object_.IsEmpty() == false); assert(wrap->object_.IsEmpty() == false);
if (status) { if (status) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
} }
wrap->UpdateWriteQueueSize(); wrap->UpdateWriteQueueSize();
@ -389,7 +389,7 @@ Handle<Value> StreamWrap::Shutdown(const Arguments& args) {
req_wrap->Dispatched(); req_wrap->Dispatched();
if (r) { if (r) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
delete req_wrap; delete req_wrap;
return scope.Close(v8::Null()); return scope.Close(v8::Null());
} else { } else {
@ -409,7 +409,7 @@ void StreamWrap::AfterShutdown(uv_shutdown_t* req, int status) {
HandleScope scope; HandleScope scope;
if (status) { if (status) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
} }
Local<Value> argv[3] = { Local<Value> argv[3] = {

28
src/tcp_wrap.cc

@ -21,7 +21,7 @@
#include <node.h> #include <node.h>
#include <node_buffer.h> #include <node_buffer.h>
#include <node_isolate.h> #include <node_vars.h>
#include <req_wrap.h> #include <req_wrap.h>
#include <handle_wrap.h> #include <handle_wrap.h>
#include <stream_wrap.h> #include <stream_wrap.h>
@ -155,7 +155,7 @@ Handle<Value> TCPWrap::New(const Arguments& args) {
TCPWrap::TCPWrap(Handle<Object> object) TCPWrap::TCPWrap(Handle<Object> object)
: StreamWrap(object, (uv_stream_t*) &handle_) { : StreamWrap(object, (uv_stream_t*) &handle_) {
int r = uv_tcp_init(NODE_LOOP(), &handle_); int r = uv_tcp_init(Loop(), &handle_);
assert(r == 0); // How do we proxy this error up to javascript? assert(r == 0); // How do we proxy this error up to javascript?
// Suggestion: uv_tcp_init() returns void. // Suggestion: uv_tcp_init() returns void.
UpdateWriteQueueSize(); UpdateWriteQueueSize();
@ -183,7 +183,7 @@ Handle<Value> TCPWrap::GetSockName(const Arguments& args) {
Local<Object> sockname = Object::New(); Local<Object> sockname = Object::New();
if (r != 0) { if (r != 0) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
} else { } else {
family = address.ss_family; family = address.ss_family;
@ -225,7 +225,7 @@ Handle<Value> TCPWrap::GetPeerName(const Arguments& args) {
Local<Object> sockname = Object::New(); Local<Object> sockname = Object::New();
if (r != 0) { if (r != 0) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
} else { } else {
family = address.ss_family; family = address.ss_family;
@ -258,7 +258,7 @@ Handle<Value> TCPWrap::SetNoDelay(const Arguments& args) {
int r = uv_tcp_nodelay(&wrap->handle_, 1); int r = uv_tcp_nodelay(&wrap->handle_, 1);
if (r) if (r)
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
return Undefined(); return Undefined();
} }
@ -274,7 +274,7 @@ Handle<Value> TCPWrap::SetKeepAlive(const Arguments& args) {
int r = uv_tcp_keepalive(&wrap->handle_, enable, delay); int r = uv_tcp_keepalive(&wrap->handle_, enable, delay);
if (r) if (r)
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
return Undefined(); return Undefined();
} }
@ -290,7 +290,7 @@ Handle<Value> TCPWrap::SetSimultaneousAccepts(const Arguments& args) {
int r = uv_tcp_simultaneous_accepts(&wrap->handle_, enable ? 1 : 0); int r = uv_tcp_simultaneous_accepts(&wrap->handle_, enable ? 1 : 0);
if (r) if (r)
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
return Undefined(); return Undefined();
} }
@ -309,7 +309,7 @@ Handle<Value> TCPWrap::Bind(const Arguments& args) {
int r = uv_tcp_bind(&wrap->handle_, address); int r = uv_tcp_bind(&wrap->handle_, address);
// Error starting the tcp. // Error starting the tcp.
if (r) SetErrno(uv_last_error(NODE_LOOP())); if (r) SetErrno(uv_last_error(Loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r));
} }
@ -327,7 +327,7 @@ Handle<Value> TCPWrap::Bind6(const Arguments& args) {
int r = uv_tcp_bind6(&wrap->handle_, address); int r = uv_tcp_bind6(&wrap->handle_, address);
// Error starting the tcp. // Error starting the tcp.
if (r) SetErrno(uv_last_error(NODE_LOOP())); if (r) SetErrno(uv_last_error(Loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r));
} }
@ -343,7 +343,7 @@ Handle<Value> TCPWrap::Listen(const Arguments& args) {
int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection); int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection);
// Error starting the tcp. // Error starting the tcp.
if (r) SetErrno(uv_last_error(NODE_LOOP())); if (r) SetErrno(uv_last_error(Loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r));
} }
@ -378,7 +378,7 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
// Successful accept. Call the onconnection callback in JavaScript land. // Successful accept. Call the onconnection callback in JavaScript land.
argv[0] = client_obj; argv[0] = client_obj;
} else { } else {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
argv[0] = v8::Null(); argv[0] = v8::Null();
} }
@ -397,7 +397,7 @@ void TCPWrap::AfterConnect(uv_connect_t* req, int status) {
assert(wrap->object_.IsEmpty() == false); assert(wrap->object_.IsEmpty() == false);
if (status) { if (status) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
} }
Local<Value> argv[3] = { Local<Value> argv[3] = {
@ -433,7 +433,7 @@ Handle<Value> TCPWrap::Connect(const Arguments& args) {
req_wrap->Dispatched(); req_wrap->Dispatched();
if (r) { if (r) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
delete req_wrap; delete req_wrap;
return scope.Close(v8::Null()); return scope.Close(v8::Null());
} else { } else {
@ -460,7 +460,7 @@ Handle<Value> TCPWrap::Connect6(const Arguments& args) {
req_wrap->Dispatched(); req_wrap->Dispatched();
if (r) { if (r) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
delete req_wrap; delete req_wrap;
return scope.Close(v8::Null()); return scope.Close(v8::Null());
} else { } else {

20
src/timer_wrap.cc

@ -21,7 +21,7 @@
#include <node.h> #include <node.h>
#include <handle_wrap.h> #include <handle_wrap.h>
#include <node_isolate.h> #include <node_vars.h>
#define UNWRAP \ #define UNWRAP \
assert(!args.Holder().IsEmpty()); \ assert(!args.Holder().IsEmpty()); \
@ -92,7 +92,7 @@ class TimerWrap : public HandleWrap {
: HandleWrap(object, (uv_handle_t*) &handle_) { : HandleWrap(object, (uv_handle_t*) &handle_) {
active_ = false; active_ = false;
int r = uv_timer_init(NODE_LOOP(), &handle_); int r = uv_timer_init(Loop(), &handle_);
assert(r == 0); assert(r == 0);
handle_.data = this; handle_.data = this;
@ -100,11 +100,11 @@ class TimerWrap : public HandleWrap {
// uv_timer_init adds a loop reference. (That is, it calls uv_ref.) This // uv_timer_init adds a loop reference. (That is, it calls uv_ref.) This
// is not the behavior we want in Node. Timers should not increase the // is not the behavior we want in Node. Timers should not increase the
// ref count of the loop except when active. // ref count of the loop except when active.
uv_unref(NODE_LOOP()); uv_unref(Loop());
} }
~TimerWrap() { ~TimerWrap() {
if (!active_) uv_ref(NODE_LOOP()); if (!active_) uv_ref(Loop());
} }
void StateChange() { void StateChange() {
@ -114,11 +114,11 @@ class TimerWrap : public HandleWrap {
if (!was_active && active_) { if (!was_active && active_) {
// If our state is changing from inactive to active, we // If our state is changing from inactive to active, we
// increase the loop's reference count. // increase the loop's reference count.
uv_ref(NODE_LOOP()); uv_ref(Loop());
} else if (was_active && !active_) { } else if (was_active && !active_) {
// If our state is changing from active to inactive, we // If our state is changing from active to inactive, we
// decrease the loop's reference count. // decrease the loop's reference count.
uv_unref(NODE_LOOP()); uv_unref(Loop());
} }
} }
@ -133,7 +133,7 @@ class TimerWrap : public HandleWrap {
int r = uv_timer_start(&wrap->handle_, OnTimeout, timeout, repeat); int r = uv_timer_start(&wrap->handle_, OnTimeout, timeout, repeat);
// Error starting the timer. // Error starting the timer.
if (r) SetErrno(uv_last_error(NODE_LOOP())); if (r) SetErrno(uv_last_error(Loop()));
wrap->StateChange(); wrap->StateChange();
@ -147,7 +147,7 @@ class TimerWrap : public HandleWrap {
int r = uv_timer_stop(&wrap->handle_); int r = uv_timer_stop(&wrap->handle_);
if (r) SetErrno(uv_last_error(NODE_LOOP())); if (r) SetErrno(uv_last_error(Loop()));
wrap->StateChange(); wrap->StateChange();
@ -161,7 +161,7 @@ class TimerWrap : public HandleWrap {
int r = uv_timer_again(&wrap->handle_); int r = uv_timer_again(&wrap->handle_);
if (r) SetErrno(uv_last_error(NODE_LOOP())); if (r) SetErrno(uv_last_error(Loop()));
wrap->StateChange(); wrap->StateChange();
@ -187,7 +187,7 @@ class TimerWrap : public HandleWrap {
int64_t repeat = uv_timer_get_repeat(&wrap->handle_); int64_t repeat = uv_timer_get_repeat(&wrap->handle_);
if (repeat < 0) SetErrno(uv_last_error(NODE_LOOP())); if (repeat < 0) SetErrno(uv_last_error(Loop()));
return scope.Close(Integer::New(repeat)); return scope.Close(Integer::New(repeat));
} }

8
src/tty_wrap.cc

@ -21,7 +21,7 @@
#include <node.h> #include <node.h>
#include <node_buffer.h> #include <node_buffer.h>
#include <node_isolate.h> #include <node_vars.h>
#include <req_wrap.h> #include <req_wrap.h>
#include <handle_wrap.h> #include <handle_wrap.h>
#include <stream_wrap.h> #include <stream_wrap.h>
@ -125,7 +125,7 @@ class TTYWrap : StreamWrap {
int r = uv_tty_get_winsize(&wrap->handle_, &width, &height); int r = uv_tty_get_winsize(&wrap->handle_, &width, &height);
if (r) { if (r) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
return v8::Undefined(); return v8::Undefined();
} }
@ -144,7 +144,7 @@ class TTYWrap : StreamWrap {
int r = uv_tty_set_mode(&wrap->handle_, args[0]->IsTrue()); int r = uv_tty_set_mode(&wrap->handle_, args[0]->IsTrue());
if (r) { if (r) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
} }
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r));
@ -170,7 +170,7 @@ class TTYWrap : StreamWrap {
TTYWrap(Handle<Object> object, int fd, bool readable) TTYWrap(Handle<Object> object, int fd, bool readable)
: StreamWrap(object, (uv_stream_t*)&handle_) { : StreamWrap(object, (uv_stream_t*)&handle_) {
uv_tty_init(NODE_LOOP(), &handle_, fd, readable); uv_tty_init(Loop(), &handle_, fd, readable);
} }
uv_tty_t handle_; uv_tty_t handle_;

18
src/udp_wrap.cc

@ -21,7 +21,7 @@
#include <node.h> #include <node.h>
#include <node_buffer.h> #include <node_buffer.h>
#include <node_isolate.h> #include <node_vars.h>
#include <req_wrap.h> #include <req_wrap.h>
#include <handle_wrap.h> #include <handle_wrap.h>
@ -104,7 +104,7 @@ private:
UDPWrap::UDPWrap(Handle<Object> object): HandleWrap(object, UDPWrap::UDPWrap(Handle<Object> object): HandleWrap(object,
(uv_handle_t*)&handle_) { (uv_handle_t*)&handle_) {
int r = uv_udp_init(NODE_LOOP(), &handle_); int r = uv_udp_init(Loop(), &handle_);
assert(r == 0); // can't fail anyway assert(r == 0); // can't fail anyway
handle_.data = reinterpret_cast<void*>(this); handle_.data = reinterpret_cast<void*>(this);
} }
@ -177,7 +177,7 @@ Handle<Value> UDPWrap::DoBind(const Arguments& args, int family) {
} }
if (r) if (r)
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
return scope.Close(Integer::New(r)); return scope.Close(Integer::New(r));
} }
@ -234,7 +234,7 @@ Handle<Value> UDPWrap::DoSend(const Arguments& args, int family) {
req_wrap->Dispatched(); req_wrap->Dispatched();
if (r) { if (r) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
delete req_wrap; delete req_wrap;
return Null(); return Null();
} }
@ -261,8 +261,8 @@ Handle<Value> UDPWrap::RecvStart(const Arguments& args) {
// UV_EALREADY means that the socket is already bound but that's okay // UV_EALREADY means that the socket is already bound but that's okay
int r = uv_udp_recv_start(&wrap->handle_, OnAlloc, OnRecv); int r = uv_udp_recv_start(&wrap->handle_, OnAlloc, OnRecv);
if (r && uv_last_error(NODE_LOOP()).code != UV_EALREADY) { if (r && uv_last_error(Loop()).code != UV_EALREADY) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
return False(); return False();
} }
@ -298,7 +298,7 @@ Handle<Value> UDPWrap::GetSockName(const Arguments& args) {
return scope.Close(sockname); return scope.Close(sockname);
} }
else { else {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
return Null(); return Null();
} }
} }
@ -317,7 +317,7 @@ void UDPWrap::OnSend(uv_udp_send_t* req, int status) {
assert(wrap->object_.IsEmpty() == false); assert(wrap->object_.IsEmpty() == false);
if (status) { if (status) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
} }
Local<Value> argv[4] = { Local<Value> argv[4] = {
@ -365,7 +365,7 @@ void UDPWrap::OnRecv(uv_udp_t* handle,
}; };
if (nread == -1) { if (nread == -1) {
SetErrno(uv_last_error(NODE_LOOP())); SetErrno(uv_last_error(Loop()));
} }
else { else {
Local<Object> rinfo = Object::New(); Local<Object> rinfo = Object::New();

Loading…
Cancel
Save