Conversation
db24841 to
6d026ad
Compare
lib/dgram.js
Outdated
There was a problem hiding this comment.
Or follow the net.js and use validateInt32. I will change it.
doc/api/dgram.md
Outdated
There was a problem hiding this comment.
A nit: I am not sure what is correct: an `fd` or a `fd`, but these two fragments need to be unified)
lib/dgram.js
Outdated
There was a problem hiding this comment.
Please use isInt32 instead. That does exactly what is necessary here.
There was a problem hiding this comment.
Thanks for your advice. As we need to make sure that the fd is greater than 0, I use isUint32 directly.
Another test is added that it should return errno when the type of fd is not "UDP".
|
@nodejs/dgram PTAL |
|
Ping @nodejs/dgram |
lib/dgram.js
Outdated
There was a problem hiding this comment.
this used to throw, but now the logic returns an error, so it's a change in API. Given that we export this, it would be a semver-major change.
I'm a bit lost on why we need this _createSocketHandle function at all. Does anyone know? If it's useful, we should remove the _. If it's not and it's useful for tests only, we should move it to internals.
There was a problem hiding this comment.
It should be in internals. It's hard to say if there is any ecosystem usage though. It's used in core by the cluster module.
There was a problem hiding this comment.
Yes, _createSocketHandle is used in cluster module to create a handle from a master process and handles like these will be shared with worker processes.
Maybe we can remove _ in other PRs as it's also named like _createServerHandle in the net module.
lib/dgram.js
Outdated
There was a problem hiding this comment.
I'm not fond of UDP requiring TTY. Maybe we should move that guessHandleType somewhere else?
There was a problem hiding this comment.
Maybe move the guessHandleType into lib/internal/util.js or lib/internal/net.js?
lib/dgram.js
Outdated
There was a problem hiding this comment.
Small detail, but I don't think we want a uint32, but rather an int32 that is not negative.
lib/dgram.js
Outdated
There was a problem hiding this comment.
Minor nit: can braces be included with the conditional's multi-line body?
lib/dgram.js
Outdated
There was a problem hiding this comment.
The indentation is off here
test/parallel/test-dgram-bind-fd.js
Outdated
There was a problem hiding this comment.
Why this timeout and the one below for the receiver?
There was a problem hiding this comment.
Thanks. It's unnecessary here.
There was a problem hiding this comment.
The receiver one is needed because calling close directly would prevent the message from being sent.
I use process.nextTick instead of the setTimeout as I think it's more precise here.
bf50fde to
21f3515
Compare
|
CI: https://ci.nodejs.org/job/node-test-pull-request/16074/
|
|
@mscdex I'm ok in landing it as a minor if there is no ecosystem usage of this. That might truly be the case. |
|
The test that failed before on Jenkins seems unrelated (see #22041). |
|
@nodejs/tsc PTAL, this need another LGTM. |
There was a problem hiding this comment.
minor nit: const { UDP } = process.binding('udp_wrap');
|
Green CI and two TSC approvals on a semver-major means this can land. Since TSC was only pinged 12 hours ago, it might be a good idea to leave it open for the weekend to give people a chance to weigh in before landing. (But that is not required.) |
dgram: Implement binding an existing `fd`. Allow pass a `fd` property to `socket.bind()` in dgram. src: Add `UDPWrap::Open` Fixes: nodejs#14961
cjihrig
left a comment
There was a problem hiding this comment.
LGTM. It might make sense to expose fd now, but don't worry about it in this PR.
|
CI: https://ci.nodejs.org/job/node-test-pull-request/16209/ (last before landing) |
|
Landed in 2bea9ce |
|
Thanks @oyyd for your first contribution to Node.js Core! 🎉 |
|
@mcollina Thanks! |
dgram: Implement binding an existing
fd. Allow passing afdproperty tosocket.bind()in dgram.src: Add
UDPWrap::Open.Cluster is also considered. All related tests are ignored on windows.
Fixes: #14961
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes