mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
worker: do not look up context twice in PostMessage
Refs: https://github.com/nodejs/node/issues/38780#issuecomment-846548949 PR-URL: https://github.com/nodejs/node/pull/38784 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
This commit is contained in:
1 parent
1ffbe3d5da
commit
2c28e00685
2 files changed
+5
-2
No files matched your search
@@ -824,11 +824,11 @@ BaseObjectPtr<BaseObject> MessagePortData::Deserialize(
|
||||
}
|
||||
|
||||
Maybe<bool> MessagePort::PostMessage(Environment* env,
|
||||
Local<Context> context,
|
||||
Local<Value> message_v,
|
||||
const TransferList& transfer_v) {
|
||||
Isolate* isolate = env->isolate();
|
||||
Local<Object> obj = object(isolate);
|
||||
Local<Context> context = obj->CreationContext();
|
||||
|
||||
Message msg;
|
||||
|
||||
@@ -970,7 +970,9 @@ void MessagePort::PostMessage(const FunctionCallbackInfo<Value>& args) {
|
||||
return;
|
||||
}
|
||||
|
||||
port->PostMessage(env, args[0], transfer_list);
|
||||
Maybe<bool> res = port->PostMessage(env, context, args[0], transfer_list);
|
||||
if (res.IsJust())
|
||||
args.GetReturnValue().Set(res.FromJust());
|
||||
}
|
||||
|
||||
void MessagePort::Start() {
|
||||
|
||||
@@ -181,6 +181,7 @@ class MessagePort : public HandleWrap {
|
||||
// If this port is closed, or if there is no sibling, this message is
|
||||
// serialized with transfers, then silently discarded.
|
||||
v8::Maybe<bool> PostMessage(Environment* env,
|
||||
v8::Local<v8::Context> context,
|
||||
v8::Local<v8::Value> message,
|
||||
const TransferList& transfer);
|
||||
|
||||
|
||||
Reference in new issue
Block a user