diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2012-01-23 22:30:28 +0400 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2012-01-23 22:30:28 +0400 |
commit | 667aae596cded9336f50574386683ec39ada43f2 (patch) | |
tree | 41918ad8d4801cc34215b054cb63dc83bd1ce8a5 /src | |
parent | 2433eeb3850a91feb99bab530cb7183800166390 (diff) | |
parent | 6c0c00a2052ec613503a0322dcbabb6fcf41dab0 (diff) |
Merge branch 'v0.6'
Conflicts:
ChangeLog
doc/template.html
lib/cluster.js
lib/http.js
lib/tls.js
src/node.h
src/node_version.h
test/simple/test-cluster-kill-workers.js
Diffstat (limited to 'src')
-rw-r--r-- | src/node_crypto.cc | 1 | ||||
-rw-r--r-- | src/udp_wrap.cc | 73 | ||||
-rw-r--r-- | src/v8_typed_array.cc | 15 |
3 files changed, 89 insertions, 0 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 7e547ee5759..59cb7fbb292 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -592,6 +592,7 @@ int Connection::HandleBIOError(BIO *bio, const char* func, int rv) { if (rv >= 0) return rv; int retry = BIO_should_retry(bio); + (void) retry; // unused if !defined(SSL_PRINT_DEBUG) if (BIO_should_write(bio)) { DEBUG_PRINT("[%p] BIO: %s want write. should retry %d\n", ssl_, func, retry); diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 6d79410779a..c3099d65ee8 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -92,6 +92,10 @@ public: static Handle<Value> RecvStart(const Arguments& args); static Handle<Value> RecvStop(const Arguments& args); static Handle<Value> GetSockName(const Arguments& args); + static Handle<Value> AddMembership(const Arguments& args); + static Handle<Value> DropMembership(const Arguments& args); + static Handle<Value> SetMulticastTTL(const Arguments& args); + static Handle<Value> SetBroadcast(const Arguments& args); private: static inline char* NewSlab(v8::Handle<v8::Object> global, v8::Handle<v8::Object> wrap_obj); @@ -101,6 +105,8 @@ private: static Handle<Value> DoBind(const Arguments& args, int family); static Handle<Value> DoSend(const Arguments& args, int family); + static Handle<Value> SetMembership(const Arguments& args, + uv_membership membership); static uv_buf_t OnAlloc(uv_handle_t* handle, size_t suggested_size); static void OnSend(uv_udp_send_t* req, int status); @@ -148,6 +154,10 @@ void UDPWrap::Initialize(Handle<Object> target) { NODE_SET_PROTOTYPE_METHOD(t, "recvStart", RecvStart); NODE_SET_PROTOTYPE_METHOD(t, "recvStop", RecvStop); NODE_SET_PROTOTYPE_METHOD(t, "getsockname", GetSockName); + 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, "setBroadcast", SetBroadcast); target->Set(String::NewSymbol("UDP"), Persistent<FunctionTemplate>::New(t)->GetFunction()); @@ -204,6 +214,69 @@ 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); + + int on = args[0]->Uint32Value(); + int r = uv_udp_set_broadcast(&wrap->handle_, on); + + if (r) + SetErrno(uv_last_error(uv_default_loop())); + + return scope.Close(Integer::New(r)); +} + +Handle<Value> UDPWrap::SetMembership(const Arguments& args, + uv_membership membership) { + HandleScope scope; + UNWRAP + + assert(args.Length() == 2); + + String::Utf8Value address(args[0]->ToString()); + String::Utf8Value interface(args[1]->ToString()); + + const char* interface_cstr = *interface; + if (args[1]->IsUndefined() || args[1]->IsNull()) { + interface_cstr = NULL; + } + + int r = uv_udp_set_membership(&wrap->handle_, *address, interface_cstr, + membership); + + if (r) + SetErrno(uv_last_error(uv_default_loop())); + + return scope.Close(Integer::New(r)); +} + + +Handle<Value> UDPWrap::AddMembership(const Arguments& args) { + return SetMembership(args, UV_JOIN_GROUP); +} + + +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; diff --git a/src/v8_typed_array.cc b/src/v8_typed_array.cc index c25f5451e5f..9941845fc55 100644 --- a/src/v8_typed_array.cc +++ b/src/v8_typed_array.cc @@ -141,6 +141,7 @@ class TypedArray { v8::HandleScope scope; ft_cache = v8::Persistent<v8::FunctionTemplate>::New( v8::FunctionTemplate::New(&TypedArray<TBytes, TEAType>::V8New)); + ft_cache->SetClassName(v8::String::New(TypeName())); v8::Local<v8::ObjectTemplate> instance = ft_cache->InstanceTemplate(); instance->SetInternalFieldCount(0); @@ -434,6 +435,20 @@ class TypedArray { return TypedArray<TBytes, TEAType>::GetTemplate()-> GetFunction()->NewInstance(3, argv); } + + static const char* TypeName() { + switch (TEAType) { + case v8::kExternalByteArray: return "Int8Array"; + case v8::kExternalUnsignedByteArray: return "Uint8Array"; + case v8::kExternalShortArray: return "Int16Array"; + case v8::kExternalUnsignedShortArray: return "Uint16Array"; + case v8::kExternalIntArray: return "Int32Array"; + case v8::kExternalUnsignedIntArray: return "Uint32Array"; + case v8::kExternalFloatArray: return "Float32Array"; + case v8::kExternalDoubleArray: return "Float64Array"; + } + abort(); + } }; class Int8Array : public TypedArray<1, v8::kExternalByteArray> { }; |