summaryrefslogtreecommitdiff
path: root/src/stream_base.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-10-29 15:15:36 +0100
committerAnna Henningsen <anna@addaleax.net>2019-11-05 23:07:04 +0100
commit973f324463a91721cc8a1158a5ab10ad0dd69019 (patch)
treea7664cbcc50c0fe7eced11fb20e49dc255abfe1e /src/stream_base.cc
parentf17e414dc4b5d80dd5b5c7ee7107659ec5ebeb1a (diff)
downloadandroid-node-v8-973f324463a91721cc8a1158a5ab10ad0dd69019.tar.gz
android-node-v8-973f324463a91721cc8a1158a5ab10ad0dd69019.tar.bz2
android-node-v8-973f324463a91721cc8a1158a5ab10ad0dd69019.zip
child_process,cluster: allow using V8 serialization API
Add an `serialization` option that allows child process IPC to use the (typically more powerful) V8 serialization API. Fixes: https://github.com/nodejs/node/issues/10965 PR-URL: https://github.com/nodejs/node/pull/30162 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'src/stream_base.cc')
-rw-r--r--src/stream_base.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/stream_base.cc b/src/stream_base.cc
index 52163e2e43..eaccfc995c 100644
--- a/src/stream_base.cc
+++ b/src/stream_base.cc
@@ -180,12 +180,26 @@ int StreamBase::WriteBuffer(const FunctionCallbackInfo<Value>& args) {
}
Local<Object> req_wrap_obj = args[0].As<Object>();
-
uv_buf_t buf;
buf.base = Buffer::Data(args[1]);
buf.len = Buffer::Length(args[1]);
- StreamWriteResult res = Write(&buf, 1, nullptr, req_wrap_obj);
+ uv_stream_t* send_handle = nullptr;
+
+ if (args[2]->IsObject() && IsIPCPipe()) {
+ Local<Object> send_handle_obj = args[2].As<Object>();
+
+ HandleWrap* wrap;
+ ASSIGN_OR_RETURN_UNWRAP(&wrap, send_handle_obj, UV_EINVAL);
+ send_handle = reinterpret_cast<uv_stream_t*>(wrap->GetHandle());
+ // Reference LibuvStreamWrap instance to prevent it from being garbage
+ // collected before `AfterWrite` is called.
+ req_wrap_obj->Set(env->context(),
+ env->handle_string(),
+ send_handle_obj).Check();
+ }
+
+ StreamWriteResult res = Write(&buf, 1, send_handle, req_wrap_obj);
SetWriteResult(res);
return res.err;