diff options
author | isaacs <i@izs.me> | 2012-02-01 06:18:00 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-02-01 06:18:00 +0400 |
commit | 18d179c2d8f916c07a763ea8e99ed6dc77751bfa (patch) | |
tree | d2066d272d5e81f21c355e0ab9b6432dcebd3c5f /src | |
parent | 33b7fc250f061af42b595decf6c0edf360c5aae9 (diff) | |
parent | 7e0bf7d57de318f45a097e05644efa49beb65209 (diff) |
Merge remote-tracking branch 'ry/v0.6' into master
Conflicts:
ChangeLog
deps/uv/src/unix/udp.c
deps/uv/src/win/fs.c
deps/uv/src/win/udp.c
deps/uv/test/test-fs.c
doc/index.html
doc/logos/index.html
doc/template.html
src/node_version.h
Diffstat (limited to 'src')
-rw-r--r-- | src/node.js | 10 | ||||
-rw-r--r-- | src/udp_wrap.cc | 43 |
2 files changed, 25 insertions, 28 deletions
diff --git a/src/node.js b/src/node.js index 8ca0da48d01..4df1e711f88 100644 --- a/src/node.js +++ b/src/node.js @@ -297,8 +297,9 @@ process.__defineGetter__('stdout', function() { if (stdout) return stdout; stdout = createWritableStdioStream(1); - stdout.end = stdout.destroy = stdout.destroySoon = function() { - throw new Error('process.stdout cannot be closed'); + stdout.destroy = stdout.destroySoon = function(er) { + er = er || new Error('process.stdout cannot be closed.'); + stdout.emit('error', er); }; return stdout; }); @@ -306,8 +307,9 @@ process.__defineGetter__('stderr', function() { if (stderr) return stderr; stderr = createWritableStdioStream(2); - stderr.end = stderr.destroy = stderr.destroySoon = function() { - throw new Error('process.stderr cannot be closed'); + stderr.destroy = stderr.destroySoon = function(er) { + er = er || new Error('process.stderr cannot be closed.'); + stderr.emit('error', er); }; return stderr; }); diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index cab42b3c277..5f4b7eed19c 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -95,7 +95,9 @@ public: static Handle<Value> AddMembership(const Arguments& args); static Handle<Value> DropMembership(const Arguments& args); static Handle<Value> SetMulticastTTL(const Arguments& args); + static Handle<Value> SetMulticastLoopback(const Arguments& args); static Handle<Value> SetBroadcast(const Arguments& args); + static Handle<Value> SetTTL(const Arguments& args); private: static inline char* NewSlab(v8::Handle<v8::Object> global, v8::Handle<v8::Object> wrap_obj); @@ -157,7 +159,9 @@ void UDPWrap::Initialize(Handle<Object> target) { NODE_SET_PROTOTYPE_METHOD(t, "addMembership", AddMembership); NODE_SET_PROTOTYPE_METHOD(t, "dropMembership", DropMembership); NODE_SET_PROTOTYPE_METHOD(t, "setMulticastTTL", SetMulticastTTL); + NODE_SET_PROTOTYPE_METHOD(t, "setMulticastLoopback", SetMulticastLoopback); NODE_SET_PROTOTYPE_METHOD(t, "setBroadcast", SetBroadcast); + NODE_SET_PROTOTYPE_METHOD(t, "setTTL", SetTTL); target->Set(String::NewSymbol("UDP"), Persistent<FunctionTemplate>::New(t)->GetFunction()); @@ -214,20 +218,25 @@ Handle<Value> UDPWrap::Bind6(const Arguments& args) { return DoBind(args, AF_INET6); } -Handle<Value> UDPWrap::SetBroadcast(const Arguments& args) { - HandleScope scope; - UNWRAP - assert(args.Length() == 1); +#define X(name, fn) \ + Handle<Value> UDPWrap::name(const Arguments& args) { \ + HandleScope scope; \ + UNWRAP \ + assert(args.Length() == 1); \ + int flag = args[0]->Int32Value(); \ + int r = fn(&wrap->handle_, flag); \ + if (r) SetErrno(uv_last_error(uv_default_loop())); \ + return scope.Close(Integer::New(r)); \ + } - int on = args[0]->Uint32Value(); - int r = uv_udp_set_broadcast(&wrap->handle_, on); +X(SetTTL, uv_udp_set_ttl) +X(SetBroadcast, uv_udp_set_broadcast) +X(SetMulticastTTL, uv_udp_set_multicast_ttl) +X(SetMulticastLoopback, uv_udp_set_multicast_loop) - if (r) - SetErrno(uv_last_error(uv_default_loop())); +#undef X - return scope.Close(Integer::New(r)); -} Handle<Value> UDPWrap::SetMembership(const Arguments& args, uv_membership membership) { @@ -263,20 +272,6 @@ Handle<Value> UDPWrap::DropMembership(const Arguments& args) { return SetMembership(args, UV_LEAVE_GROUP); } -Handle<Value> UDPWrap::SetMulticastTTL(const Arguments& args) { - HandleScope scope; - UNWRAP - - assert(args.Length() == 1); - - int ttl = args[0]->Uint32Value(); - int r = uv_udp_set_multicast_ttl(&wrap->handle_, ttl); - - if (r) - SetErrno(uv_last_error(uv_default_loop())); - - return scope.Close(Integer::New(r)); -} Handle<Value> UDPWrap::DoSend(const Arguments& args, int family) { HandleScope scope; |