aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/ext
diff options
context:
space:
mode:
Diffstat (limited to 'src/node/ext')
-rw-r--r--src/node/ext/byte_buffer.cc1
-rw-r--r--src/node/ext/call.cc12
-rw-r--r--src/node/ext/call_credentials.cc5
-rw-r--r--src/node/ext/call_credentials.h2
4 files changed, 16 insertions, 4 deletions
diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc
index e1786ddba7..c306292c04 100644
--- a/src/node/ext/byte_buffer.cc
+++ b/src/node/ext/byte_buffer.cc
@@ -77,6 +77,7 @@ Local<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) {
while (grpc_byte_buffer_reader_next(&reader, &next) != 0) {
memcpy(result + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next));
offset += GPR_SLICE_LENGTH(next);
+ gpr_slice_unref(next);
}
return scope.Escape(MakeFastBuffer(
Nan::NewBuffer(result, length).ToLocalChecked()));
diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc
index a98ae85427..1b2ab21dfe 100644
--- a/src/node/ext/call.cc
+++ b/src/node/ext/call.cc
@@ -234,6 +234,12 @@ class SendMetadataOp : public Op {
class SendMessageOp : public Op {
public:
+ SendMessageOp() { send_message = NULL; }
+ ~SendMessageOp() {
+ if (send_message != NULL) {
+ grpc_byte_buffer_destroy(send_message);
+ }
+ }
Local<Value> GetNodeValue() const {
EscapableHandleScope scope;
return scope.Escape(Nan::True());
@@ -253,7 +259,8 @@ class SendMessageOp : public Op {
out->flags = maybe_flag.FromMaybe(0) & GRPC_WRITE_USED_MASK;
}
}
- out->data.send_message = BufferToByteBuffer(value);
+ send_message = BufferToByteBuffer(value);
+ out->data.send_message = send_message;
PersistentValue *handle = new PersistentValue(value);
resources->handles.push_back(unique_ptr<PersistentValue>(handle));
return true;
@@ -262,6 +269,9 @@ class SendMessageOp : public Op {
std::string GetTypeString() const {
return "send_message";
}
+
+ private:
+ grpc_byte_buffer *send_message;
};
class SendClientCloseOp : public Op {
diff --git a/src/node/ext/call_credentials.cc b/src/node/ext/call_credentials.cc
index 9c5d9d291b..8cbfb1ebea 100644
--- a/src/node/ext/call_credentials.cc
+++ b/src/node/ext/call_credentials.cc
@@ -162,6 +162,7 @@ NAN_METHOD(CallCredentials::CreateFromPlugin) {
plugin.get_metadata = plugin_get_metadata;
plugin.destroy = plugin_destroy_state;
plugin.state = reinterpret_cast<void*>(state);
+ plugin.type = "";
grpc_call_credentials *creds = grpc_metadata_credentials_create_from_plugin(
plugin, NULL);
info.GetReturnValue().Set(WrapStruct(creds));
@@ -225,7 +226,7 @@ NAUV_WORK_CB(SendPluginCallback) {
uv_close((uv_handle_t *)async, (uv_close_cb)free);
}
-void plugin_get_metadata(void *state, const char *service_url,
+void plugin_get_metadata(void *state, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb,
void *user_data) {
uv_async_t *async = static_cast<uv_async_t*>(malloc(sizeof(uv_async_t)));
@@ -234,7 +235,7 @@ void plugin_get_metadata(void *state, const char *service_url,
SendPluginCallback);
plugin_callback_data *data = new plugin_callback_data;
data->state = reinterpret_cast<plugin_state*>(state);
- data->service_url = service_url;
+ data->service_url = context.service_url;
data->cb = cb;
data->user_data = user_data;
async->data = data;
diff --git a/src/node/ext/call_credentials.h b/src/node/ext/call_credentials.h
index 1cd8d8dd5d..a9bfe30f94 100644
--- a/src/node/ext/call_credentials.h
+++ b/src/node/ext/call_credentials.h
@@ -84,7 +84,7 @@ typedef struct plugin_callback_data {
void *user_data;
} plugin_callback_data;
-void plugin_get_metadata(void *state, const char *service_url,
+void plugin_get_metadata(void *state, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb,
void *user_data);