-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Dgram buffers #13623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dgram buffers #13623
Changes from 1 commit
9d6cd42
b84bf95
8aed7aa
f7c1aa6
a99ec11
2581c09
b0ac4ff
f6bf7f2
d5789c0
cd79a58
de458d1
f196be9
f4d3564
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,6 +222,36 @@ void UDPWrap::Bind6(const FunctionCallbackInfo<Value>& args) { | |
| } | ||
|
|
||
|
|
||
| void UDPWrap::SetRecvBufferSize(const FunctionCallbackInfo<Value>& args) { | ||
| UDPWrap* wrap; | ||
| ASSIGN_OR_RETURN_UNWRAP(&wrap, | ||
| args.Holder(), | ||
| args.GetReturnValue().Set(UV_EBADF)); | ||
|
|
||
| CHECK(args[0]->IsUint32()); | ||
|
|
||
| int inputSize = args[0]->Uint32Value(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we generally prefer camelCase for JavaScript and snake case for C++.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, will see to this.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That’s not necessary if you already checked |
||
| int err = uv_recv_buffer_size(reinterpret_cast<uv_handle_t*>(&wrap->handle_), &inputSize); | ||
|
|
||
| args.GetReturnValue().Set(err); | ||
| } | ||
|
|
||
|
|
||
| void UDPWrap::SetSendBufferSize(const FunctionCallbackInfo<Value>& args) { | ||
| UDPWrap* wrap; | ||
| ASSIGN_OR_RETURN_UNWRAP(&wrap, | ||
| args.Holder(), | ||
| args.GetReturnValue().Set(UV_EBADF)); | ||
|
|
||
| CHECK(args[0]->IsUint32()); | ||
|
|
||
| int inputSize = args[0]->Uint32Value(); | ||
| int err = uv_send_buffer_size(reinterpret_cast<uv_handle_t*>(&wrap->handle_), &inputSize); | ||
|
|
||
| args.GetReturnValue().Set(err); | ||
| } | ||
|
|
||
|
|
||
| #define X(name, fn) \ | ||
| void UDPWrap::name(const FunctionCallbackInfo<Value>& args) { \ | ||
| UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder()); \ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't want to crash when the user does
socket.setRecvBufferSize(Infinity). Throwing a TypeError should be a better choice.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TimothyGu you mean on the JS side, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted, do you recommend:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend doing the type check in JS. Just something simple like:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your input. Do you think I need to do any safety checking in udp_wrap.cc SetRecvBufferSize() or we assume only dgram.js will interact with udp_wrap ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, once the type checking is added to the js side, I would keep the CHECK in place on the native side. That should only be hit if we do something wrong in core or if the user is doing something they really shouldn't.