aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/ext
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2015-08-08 01:45:38 +0200
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2015-08-08 01:45:38 +0200
commit9d72b149a9e3462c2fa13afa27a1e52bfe7bf186 (patch)
treeeedff1af6f56fc97e61c3bee236b109b6d007d69 /src/node/ext
parentf75df57a8ffaddb11f064dfa5e54ec8404a81e08 (diff)
parent95a98ca768683f3864b1aefc9d6f266b22705b2a (diff)
Merge branch 'master' of github.com:grpc/grpc into the-ultimate-showdown
Conflicts: include/grpc/grpc.h src/core/surface/channel.c src/core/surface/channel_create.c src/core/surface/completion_queue.c src/cpp/client/channel.cc src/cpp/client/insecure_credentials.cc src/csharp/ext/grpc_csharp_ext.c src/node/ext/call.cc src/node/ext/channel.cc src/php/ext/grpc/call.c src/php/ext/grpc/channel.c src/python/grpcio/grpc/_adapter/_c/types/channel.c src/ruby/ext/grpc/rb_channel.c test/core/end2end/dualstack_socket_test.c test/core/end2end/fixtures/chttp2_fullstack.c test/core/end2end/fixtures/chttp2_fullstack_compression.c test/core/end2end/fixtures/chttp2_fullstack_uds_posix.c test/core/end2end/fixtures/chttp2_fullstack_with_poll.c test/core/end2end/multiple_server_queues_test.c test/core/end2end/no_server_test.c test/core/end2end/tests/bad_hostname.c test/core/end2end/tests/cancel_after_accept.c test/core/end2end/tests/cancel_after_accept_and_writes_closed.c test/core/end2end/tests/cancel_after_invoke.c test/core/end2end/tests/cancel_before_invoke.c test/core/end2end/tests/cancel_in_a_vacuum.c test/core/end2end/tests/census_simple_request.c test/core/end2end/tests/disappearing_server.c test/core/end2end/tests/early_server_shutdown_finishes_inflight_calls.c test/core/end2end/tests/empty_batch.c test/core/end2end/tests/graceful_server_shutdown.c test/core/end2end/tests/invoke_large_request.c test/core/end2end/tests/max_concurrent_streams.c test/core/end2end/tests/max_message_length.c test/core/end2end/tests/ping_pong_streaming.c test/core/end2end/tests/registered_call.c test/core/end2end/tests/request_response_with_binary_metadata_and_payload.c test/core/end2end/tests/request_response_with_metadata_and_payload.c test/core/end2end/tests/request_response_with_payload.c test/core/end2end/tests/request_response_with_payload_and_call_creds.c test/core/end2end/tests/request_response_with_trailing_metadata_and_payload.c test/core/end2end/tests/request_with_compressed_payload.c test/core/end2end/tests/request_with_flags.c test/core/end2end/tests/request_with_large_metadata.c test/core/end2end/tests/request_with_payload.c test/core/end2end/tests/server_finishes_request.c test/core/end2end/tests/simple_delayed_request.c test/core/end2end/tests/simple_request.c test/core/end2end/tests/simple_request_with_high_initial_sequence_number.c test/core/fling/client.c test/core/fling/server.c test/core/surface/lame_client_test.c
Diffstat (limited to 'src/node/ext')
-rw-r--r--src/node/ext/call.cc27
-rw-r--r--src/node/ext/call.h1
-rw-r--r--src/node/ext/channel.cc65
-rw-r--r--src/node/ext/channel.h1
-rw-r--r--src/node/ext/credentials.cc54
-rw-r--r--src/node/ext/credentials.h1
-rw-r--r--src/node/ext/server.cc46
-rw-r--r--src/node/ext/server.h1
-rw-r--r--src/node/ext/server_credentials.cc22
-rw-r--r--src/node/ext/server_credentials.h2
-rw-r--r--src/node/ext/timeval.cc1
11 files changed, 129 insertions, 92 deletions
diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc
index 4dd7081303..7e677ebd67 100644
--- a/src/node/ext/call.cc
+++ b/src/node/ext/call.cc
@@ -192,7 +192,7 @@ class SendMetadataOp : public Op {
}
protected:
std::string GetTypeString() const {
- return "send metadata";
+ return "send_metadata";
}
};
@@ -216,7 +216,7 @@ class SendMessageOp : public Op {
}
protected:
std::string GetTypeString() const {
- return "send message";
+ return "send_message";
}
};
@@ -232,7 +232,7 @@ class SendClientCloseOp : public Op {
}
protected:
std::string GetTypeString() const {
- return "client close";
+ return "client_close";
}
};
@@ -276,7 +276,7 @@ class SendServerStatusOp : public Op {
}
protected:
std::string GetTypeString() const {
- return "send status";
+ return "send_status";
}
};
@@ -453,6 +453,8 @@ void Call::Init(Handle<Object> exports) {
NanNew<FunctionTemplate>(StartBatch)->GetFunction());
NanSetPrototypeTemplate(tpl, "cancel",
NanNew<FunctionTemplate>(Cancel)->GetFunction());
+ NanSetPrototypeTemplate(tpl, "getPeer",
+ NanNew<FunctionTemplate>(GetPeer)->GetFunction());
NanAssignPersistent(fun_tpl, tpl);
Handle<Function> ctr = tpl->GetFunction();
ctr->Set(NanNew("WRITE_BUFFER_HINT"),
@@ -509,8 +511,9 @@ NAN_METHOD(Call::New) {
double deadline = args[2]->NumberValue();
grpc_channel *wrapped_channel = channel->GetWrappedChannel();
grpc_call *wrapped_call = grpc_channel_create_call(
- wrapped_channel, CompletionQueueAsyncWorker::GetQueue(), *method,
- channel->GetHost(), MillisecondsToTimespec(deadline), NULL);
+ wrapped_channel, NULL, GRPC_PROPAGATE_DEFAULTS,
+ CompletionQueueAsyncWorker::GetQueue(), *method, channel->GetHost(),
+ MillisecondsToTimespec(deadline), NULL);
call = new Call(wrapped_call);
args.This()->SetHiddenValue(NanNew("channel_"), channel_object);
}
@@ -608,5 +611,17 @@ NAN_METHOD(Call::Cancel) {
NanReturnUndefined();
}
+NAN_METHOD(Call::GetPeer) {
+ NanScope();
+ if (!HasInstance(args.This())) {
+ return NanThrowTypeError("getPeer can only be called on Call objects");
+ }
+ Call *call = ObjectWrap::Unwrap<Call>(args.This());
+ char *peer = grpc_call_get_peer(call->wrapped_call);
+ Handle<Value> peer_value = NanNew(peer);
+ gpr_free(peer);
+ NanReturnValue(peer_value);
+}
+
} // namespace node
} // namespace grpc
diff --git a/src/node/ext/call.h b/src/node/ext/call.h
index 43142c7091..6acda76197 100644
--- a/src/node/ext/call.h
+++ b/src/node/ext/call.h
@@ -120,6 +120,7 @@ class Call : public ::node::ObjectWrap {
static NAN_METHOD(New);
static NAN_METHOD(StartBatch);
static NAN_METHOD(Cancel);
+ static NAN_METHOD(GetPeer);
static NanCallback *constructor;
// Used for typechecking instances of this javascript class
static v8::Persistent<v8::FunctionTemplate> fun_tpl;
diff --git a/src/node/ext/channel.cc b/src/node/ext/channel.cc
index 15f121e855..53b1522f46 100644
--- a/src/node/ext/channel.cc
+++ b/src/node/ext/channel.cc
@@ -76,6 +76,8 @@ void Channel::Init(Handle<Object> exports) {
tpl->InstanceTemplate()->SetInternalFieldCount(1);
NanSetPrototypeTemplate(tpl, "close",
NanNew<FunctionTemplate>(Close)->GetFunction());
+ NanSetPrototypeTemplate(tpl, "getTarget",
+ NanNew<FunctionTemplate>(GetTarget)->GetFunction());
NanAssignPersistent(fun_tpl, tpl);
Handle<Function> ctr = tpl->GetFunction();
constructor = new NanCallback(ctr);
@@ -96,31 +98,30 @@ NAN_METHOD(Channel::New) {
if (args.IsConstructCall()) {
if (!args[0]->IsString()) {
- return NanThrowTypeError("Channel expects a string and an object");
+ return NanThrowTypeError(
+ "Channel expects a string, a credential and an object");
}
grpc_channel *wrapped_channel;
// Owned by the Channel object
NanUtf8String *host = new NanUtf8String(args[0]);
NanUtf8String *host_override = NULL;
- if (args[1]->IsUndefined()) {
- wrapped_channel = grpc_channel_create(**host, NULL, NULL);
- } else if (args[1]->IsObject()) {
- grpc_credentials *creds = NULL;
- Handle<Object> args_hash(args[1]->ToObject()->Clone());
+ grpc_credentials *creds;
+ if (!Credentials::HasInstance(args[1])) {
+ return NanThrowTypeError(
+ "Channel's second argument must be a credential");
+ }
+ Credentials *creds_object = ObjectWrap::Unwrap<Credentials>(
+ args[1]->ToObject());
+ creds = creds_object->GetWrappedCredentials();
+ grpc_channel_args *channel_args_ptr;
+ if (args[2]->IsUndefined()) {
+ channel_args_ptr = NULL;
+ wrapped_channel = grpc_insecure_channel_create(**host, NULL, NULL);
+ } else if (args[2]->IsObject()) {
+ Handle<Object> args_hash(args[2]->ToObject()->Clone());
if (args_hash->HasOwnProperty(NanNew(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG))) {
host_override = new NanUtf8String(args_hash->Get(NanNew(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG)));
}
- if (args_hash->HasOwnProperty(NanNew("credentials"))) {
- Handle<Value> creds_value = args_hash->Get(NanNew("credentials"));
- if (!Credentials::HasInstance(creds_value)) {
- return NanThrowTypeError(
- "credentials arg must be a Credentials object");
- }
- Credentials *creds_object =
- ObjectWrap::Unwrap<Credentials>(creds_value->ToObject());
- creds = creds_object->GetWrappedCredentials();
- args_hash->Delete(NanNew("credentials"));
- }
Handle<Array> keys(args_hash->GetOwnPropertyNames());
grpc_channel_args channel_args;
channel_args.num_args = keys->Length();
@@ -147,16 +148,19 @@ NAN_METHOD(Channel::New) {
return NanThrowTypeError("Arg values must be strings");
}
}
- if (creds == NULL) {
- wrapped_channel = grpc_channel_create(**host, &channel_args, NULL);
- } else {
- wrapped_channel =
- grpc_secure_channel_create(creds, **host, &channel_args);
- }
- free(channel_args.args);
+ channel_args_ptr = &channel_args;
} else {
return NanThrowTypeError("Channel expects a string and an object");
}
+ if (creds == NULL) {
+ wrapped_channel = grpc_insecure_channel_create(**host, channel_args_ptr);
+ } else {
+ wrapped_channel =
+ grpc_secure_channel_create(creds, **host, channel_args_ptr);
+ }
+ if (channel_args_ptr != NULL) {
+ free(channel_args_ptr->args);
+ }
Channel *channel;
if (host_override == NULL) {
channel = new Channel(wrapped_channel, host);
@@ -166,8 +170,8 @@ NAN_METHOD(Channel::New) {
channel->Wrap(args.This());
NanReturnValue(args.This());
} else {
- const int argc = 2;
- Local<Value> argv[argc] = {args[0], args[1]};
+ const int argc = 3;
+ Local<Value> argv[argc] = {args[0], args[1], args[2]};
NanReturnValue(constructor->GetFunction()->NewInstance(argc, argv));
}
}
@@ -185,5 +189,14 @@ NAN_METHOD(Channel::Close) {
NanReturnUndefined();
}
+NAN_METHOD(Channel::GetTarget) {
+ NanScope();
+ if (!HasInstance(args.This())) {
+ return NanThrowTypeError("getTarget can only be called on Channel objects");
+ }
+ Channel *channel = ObjectWrap::Unwrap<Channel>(args.This());
+ NanReturnValue(NanNew(grpc_channel_get_target(channel->wrapped_channel)));
+}
+
} // namespace node
} // namespace grpc
diff --git a/src/node/ext/channel.h b/src/node/ext/channel.h
index b3aa0f700f..6725ebb03f 100644
--- a/src/node/ext/channel.h
+++ b/src/node/ext/channel.h
@@ -66,6 +66,7 @@ class Channel : public ::node::ObjectWrap {
static NAN_METHOD(New);
static NAN_METHOD(Close);
+ static NAN_METHOD(GetTarget);
static NanCallback *constructor;
static v8::Persistent<v8::FunctionTemplate> fun_tpl;
diff --git a/src/node/ext/credentials.cc b/src/node/ext/credentials.cc
index 34872017ea..21d61f1a7f 100644
--- a/src/node/ext/credentials.cc
+++ b/src/node/ext/credentials.cc
@@ -79,10 +79,10 @@ void Credentials::Init(Handle<Object> exports) {
NanNew<FunctionTemplate>(CreateComposite)->GetFunction());
ctr->Set(NanNew("createGce"),
NanNew<FunctionTemplate>(CreateGce)->GetFunction());
- ctr->Set(NanNew("createFake"),
- NanNew<FunctionTemplate>(CreateFake)->GetFunction());
ctr->Set(NanNew("createIam"),
NanNew<FunctionTemplate>(CreateIam)->GetFunction());
+ ctr->Set(NanNew("createInsecure"),
+ NanNew<FunctionTemplate>(CreateInsecure)->GetFunction());
constructor = new NanCallback(ctr);
exports->Set(NanNew("Credentials"), ctr);
}
@@ -94,9 +94,6 @@ bool Credentials::HasInstance(Handle<Value> val) {
Handle<Value> Credentials::WrapStruct(grpc_credentials *credentials) {
NanEscapableScope();
- if (credentials == NULL) {
- return NanEscapeScope(NanNull());
- }
const int argc = 1;
Handle<Value> argv[argc] = {
NanNew<External>(reinterpret_cast<void *>(credentials))};
@@ -130,7 +127,11 @@ NAN_METHOD(Credentials::New) {
NAN_METHOD(Credentials::CreateDefault) {
NanScope();
- NanReturnValue(WrapStruct(grpc_google_default_credentials_create()));
+ grpc_credentials *creds = grpc_google_default_credentials_create();
+ if (creds == NULL) {
+ NanReturnNull();
+ }
+ NanReturnValue(WrapStruct(creds));
}
NAN_METHOD(Credentials::CreateSsl) {
@@ -154,9 +155,12 @@ NAN_METHOD(Credentials::CreateSsl) {
return NanThrowTypeError(
"createSSl's third argument must be a Buffer if provided");
}
-
- NanReturnValue(WrapStruct(grpc_ssl_credentials_create(
- root_certs, key_cert_pair.private_key == NULL ? NULL : &key_cert_pair)));
+ grpc_credentials *creds = grpc_ssl_credentials_create(
+ root_certs, key_cert_pair.private_key == NULL ? NULL : &key_cert_pair);
+ if (creds == NULL) {
+ NanReturnNull();
+ }
+ NanReturnValue(WrapStruct(creds));
}
NAN_METHOD(Credentials::CreateComposite) {
@@ -171,18 +175,21 @@ NAN_METHOD(Credentials::CreateComposite) {
}
Credentials *creds1 = ObjectWrap::Unwrap<Credentials>(args[0]->ToObject());
Credentials *creds2 = ObjectWrap::Unwrap<Credentials>(args[1]->ToObject());
- NanReturnValue(WrapStruct(grpc_composite_credentials_create(
- creds1->wrapped_credentials, creds2->wrapped_credentials)));
+ grpc_credentials *creds = grpc_composite_credentials_create(
+ creds1->wrapped_credentials, creds2->wrapped_credentials);
+ if (creds == NULL) {
+ NanReturnNull();
+ }
+ NanReturnValue(WrapStruct(creds));
}
NAN_METHOD(Credentials::CreateGce) {
NanScope();
- NanReturnValue(WrapStruct(grpc_compute_engine_credentials_create()));
-}
-
-NAN_METHOD(Credentials::CreateFake) {
- NanScope();
- NanReturnValue(WrapStruct(grpc_fake_transport_security_credentials_create()));
+ grpc_credentials *creds = grpc_compute_engine_credentials_create();
+ if (creds == NULL) {
+ NanReturnNull();
+ }
+ NanReturnValue(WrapStruct(creds));
}
NAN_METHOD(Credentials::CreateIam) {
@@ -195,8 +202,17 @@ NAN_METHOD(Credentials::CreateIam) {
}
NanUtf8String auth_token(args[0]);
NanUtf8String auth_selector(args[1]);
- NanReturnValue(
- WrapStruct(grpc_iam_credentials_create(*auth_token, *auth_selector)));
+ grpc_credentials *creds = grpc_iam_credentials_create(*auth_token,
+ *auth_selector);
+ if (creds == NULL) {
+ NanReturnNull();
+ }
+ NanReturnValue(WrapStruct(creds));
+}
+
+NAN_METHOD(Credentials::CreateInsecure) {
+ NanScope();
+ NanReturnValue(WrapStruct(NULL));
}
} // namespace node
diff --git a/src/node/ext/credentials.h b/src/node/ext/credentials.h
index 794736fe1a..62957e61c3 100644
--- a/src/node/ext/credentials.h
+++ b/src/node/ext/credentials.h
@@ -68,6 +68,7 @@ class Credentials : public ::node::ObjectWrap {
static NAN_METHOD(CreateGce);
static NAN_METHOD(CreateFake);
static NAN_METHOD(CreateIam);
+ static NAN_METHOD(CreateInsecure);
static NanCallback *constructor;
// Used for typechecking instances of this javascript class
static v8::Persistent<v8::FunctionTemplate> fun_tpl;
diff --git a/src/node/ext/server.cc b/src/node/ext/server.cc
index a123da852f..53342c0068 100644
--- a/src/node/ext/server.cc
+++ b/src/node/ext/server.cc
@@ -108,7 +108,7 @@ class NewCallOp : public Op {
protected:
std::string GetTypeString() const {
- return "new call";
+ return "new_call";
}
};
@@ -136,10 +136,6 @@ void Server::Init(Handle<Object> exports) {
tpl, "addHttp2Port",
NanNew<FunctionTemplate>(AddHttp2Port)->GetFunction());
- NanSetPrototypeTemplate(
- tpl, "addSecureHttp2Port",
- NanNew<FunctionTemplate>(AddSecureHttp2Port)->GetFunction());
-
NanSetPrototypeTemplate(tpl, "start",
NanNew<FunctionTemplate>(Start)->GetFunction());
@@ -248,43 +244,35 @@ NAN_METHOD(Server::RequestCall) {
NAN_METHOD(Server::AddHttp2Port) {
NanScope();
if (!HasInstance(args.This())) {
- return NanThrowTypeError("addHttp2Port can only be called on a Server");
- }
- if (!args[0]->IsString()) {
- return NanThrowTypeError("addHttp2Port's argument must be a String");
- }
- Server *server = ObjectWrap::Unwrap<Server>(args.This());
- if (server->wrapped_server == NULL) {
- return NanThrowError("addHttp2Port cannot be called on a shut down Server");
- }
- NanReturnValue(NanNew<Number>(grpc_server_add_http2_port(
- server->wrapped_server, *NanUtf8String(args[0]))));
-}
-
-NAN_METHOD(Server::AddSecureHttp2Port) {
- NanScope();
- if (!HasInstance(args.This())) {
return NanThrowTypeError(
- "addSecureHttp2Port can only be called on a Server");
+ "addHttp2Port can only be called on a Server");
}
if (!args[0]->IsString()) {
return NanThrowTypeError(
- "addSecureHttp2Port's first argument must be a String");
+ "addHttp2Port's first argument must be a String");
}
if (!ServerCredentials::HasInstance(args[1])) {
return NanThrowTypeError(
- "addSecureHttp2Port's second argument must be ServerCredentials");
+ "addHttp2Port's second argument must be ServerCredentials");
}
Server *server = ObjectWrap::Unwrap<Server>(args.This());
if (server->wrapped_server == NULL) {
return NanThrowError(
- "addSecureHttp2Port cannot be called on a shut down Server");
+ "addHttp2Port cannot be called on a shut down Server");
}
- ServerCredentials *creds = ObjectWrap::Unwrap<ServerCredentials>(
+ ServerCredentials *creds_object = ObjectWrap::Unwrap<ServerCredentials>(
args[1]->ToObject());
- NanReturnValue(NanNew<Number>(grpc_server_add_secure_http2_port(
- server->wrapped_server, *NanUtf8String(args[0]),
- creds->GetWrappedServerCredentials())));
+ grpc_server_credentials *creds = creds_object->GetWrappedServerCredentials();
+ int port;
+ if (creds == NULL) {
+ port = grpc_server_add_insecure_http2_port(server->wrapped_server,
+ *NanUtf8String(args[0]));
+ } else {
+ port = grpc_server_add_secure_http2_port(server->wrapped_server,
+ *NanUtf8String(args[0]),
+ creds);
+ }
+ NanReturnValue(NanNew<Number>(port));
}
NAN_METHOD(Server::Start) {
diff --git a/src/node/ext/server.h b/src/node/ext/server.h
index 5b4b18a0e0..faab7e3418 100644
--- a/src/node/ext/server.h
+++ b/src/node/ext/server.h
@@ -66,7 +66,6 @@ class Server : public ::node::ObjectWrap {
static NAN_METHOD(New);
static NAN_METHOD(RequestCall);
static NAN_METHOD(AddHttp2Port);
- static NAN_METHOD(AddSecureHttp2Port);
static NAN_METHOD(Start);
static NAN_METHOD(Shutdown);
static NanCallback *constructor;
diff --git a/src/node/ext/server_credentials.cc b/src/node/ext/server_credentials.cc
index d2b63cdc4e..1b8e7b43fb 100644
--- a/src/node/ext/server_credentials.cc
+++ b/src/node/ext/server_credentials.cc
@@ -73,8 +73,8 @@ void ServerCredentials::Init(Handle<Object> exports) {
Handle<Function> ctr = tpl->GetFunction();
ctr->Set(NanNew("createSsl"),
NanNew<FunctionTemplate>(CreateSsl)->GetFunction());
- ctr->Set(NanNew("createFake"),
- NanNew<FunctionTemplate>(CreateFake)->GetFunction());
+ ctr->Set(NanNew("createInsecure"),
+ NanNew<FunctionTemplate>(CreateInsecure)->GetFunction());
constructor = new NanCallback(ctr);
exports->Set(NanNew("ServerCredentials"), ctr);
}
@@ -87,9 +87,6 @@ bool ServerCredentials::HasInstance(Handle<Value> val) {
Handle<Value> ServerCredentials::WrapStruct(
grpc_server_credentials *credentials) {
NanEscapableScope();
- if (credentials == NULL) {
- return NanEscapeScope(NanNull());
- }
const int argc = 1;
Handle<Value> argv[argc] = {
NanNew<External>(reinterpret_cast<void *>(credentials))};
@@ -140,14 +137,19 @@ NAN_METHOD(ServerCredentials::CreateSsl) {
return NanThrowTypeError("createSsl's third argument must be a Buffer");
}
key_cert_pair.cert_chain = ::node::Buffer::Data(args[2]);
- NanReturnValue(WrapStruct(
- grpc_ssl_server_credentials_create(root_certs, &key_cert_pair, 1)));
+ // TODO Add a force_client_auth parameter and pass it as the last parameter
+ // here.
+ grpc_server_credentials *creds =
+ grpc_ssl_server_credentials_create(root_certs, &key_cert_pair, 1, 0);
+ if (creds == NULL) {
+ NanReturnNull();
+ }
+ NanReturnValue(WrapStruct(creds));
}
-NAN_METHOD(ServerCredentials::CreateFake) {
+NAN_METHOD(ServerCredentials::CreateInsecure) {
NanScope();
- NanReturnValue(
- WrapStruct(grpc_fake_transport_security_server_credentials_create()));
+ NanReturnValue(WrapStruct(NULL));
}
} // namespace node
diff --git a/src/node/ext/server_credentials.h b/src/node/ext/server_credentials.h
index aaa7ef297a..63903f663c 100644
--- a/src/node/ext/server_credentials.h
+++ b/src/node/ext/server_credentials.h
@@ -63,7 +63,7 @@ class ServerCredentials : public ::node::ObjectWrap {
static NAN_METHOD(New);
static NAN_METHOD(CreateSsl);
- static NAN_METHOD(CreateFake);
+ static NAN_METHOD(CreateInsecure);
static NanCallback *constructor;
// Used for typechecking instances of this javascript class
static v8::Persistent<v8::FunctionTemplate> fun_tpl;
diff --git a/src/node/ext/timeval.cc b/src/node/ext/timeval.cc
index 60de4d816d..bf68513c48 100644
--- a/src/node/ext/timeval.cc
+++ b/src/node/ext/timeval.cc
@@ -52,6 +52,7 @@ gpr_timespec MillisecondsToTimespec(double millis) {
}
double TimespecToMilliseconds(gpr_timespec timespec) {
+ timespec = gpr_convert_clock_type(timespec, GPR_CLOCK_REALTIME);
if (gpr_time_cmp(timespec, gpr_inf_future(GPR_CLOCK_REALTIME)) == 0) {
return std::numeric_limits<double>::infinity();
} else if (gpr_time_cmp(timespec, gpr_inf_past(GPR_CLOCK_REALTIME)) == 0) {