-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat(ext/net): Add Conn.setNoDelay and Conn.setKeepAlive #13103
Conversation
@bnoordhuis Can I ask your opinion on this implementation? Any suggestions or changes to make? Thanks! |
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 the PR. Left some comments but mostly LGTM.
Disabling Nagle isn't directly observable so there isn't a good way to verify it's actually working but there should at least be a test that verifies the API method exists.
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.
It's best to best opcall args directly without any wrapping when possible (both for performance and simplicity). Given op_set_nodelay
takes 2 args (rid, true/false)
there's no need to wrap that in a composite struct since opcalls have a user-available arity of 2.
I added suggestions of the required changes below that you can commit
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.
LGTM, thanks! I'll dismiss Aaron's review, his feedback has been addressed.
This still needs a test, by the way. |
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.
Are we sure this should be a stable API from the get go?
I'm not sure what should qualify for this to be included in the stable API. It's true that currently I don't think we can write a test for this since we need to get |
What is the problem with getting |
The idea that I have for the unit test is to call Deno.connect, get the TcpStream, and assert that nodelay and keepalive are disabled. Then, call op_set_nodelay and op_set_keepalive function and assert that nodelay and keepalive is enabled. But I don't know how to call that in test environment. It's a combination of calling Deno code, and get the TcpStream via Rust. |
The unit test implementation for the op_set_nodelay and op_set_keepalive is a little bit much. Not sure what you guys think. Please advise if it's necessary or how to make it more simple. I'm open to suggestions. |
Ah I see what you mean here. Indeed this is rather involved to check. Let me think about it and I'll get back to you. |
assertEquals(3, buf[2]); | ||
assert(conn.rid > 0); | ||
|
||
assert(readResult !== null); |
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.
Considering that:
- L262 already checks whether
readResult
equals3
readResult
is aconst
and assigned a primitive
Do we need this assertion or is it redundant?
assertEquals(3, buf[2]); | ||
assert(conn.rid > 0); | ||
|
||
assert(readResult !== null); |
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.
Same here, since readResult
is a const
to which a primitive gets assigned and whose value we assert upon on L298, isn't this assertion redundant?
Apologies if I'm missing anything here (this is also probably just a nitpick anyway, so I'm sorry).
These methods have no directly observable side effects and should therefore be safe to turn into no-ops. Doing so unblocks a number of third-party modules. Can be implemented once denoland/deno#13103 lands.
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.
LGTM, thank you @yos1p!
Implement setNoDelay function for Deno
Closes #13057
Closes #13543