| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
As mentioned in the comment of the changed file, "a libuv limitation makes it necessary to bind()". But, that is not the case anymore. So, it(meaning 'bind()') can be removed.
Sorry, something went wrong.
|
This is incorrect. It's true that now sockets can be created early by using uv_udp_init_ex(loop, handle, af), but Node doesn't do that: https://github.com/nodejs/node/blob/master/src/udp_wrap.cc#L70 AFAIS we already know the socket family when the handle is created: https://github.com/nodejs/node/blob/master/lib/dgram.js#L41 so creating the socket early would make some sense here. That way we can fail early in case of EMFILE, and not in bind(), which can be unexpected. Now, that implies that the constructor will have to throw here: https://github.com/nodejs/node/blob/master/src/udp_wrap.cc#L71 so some handling would be required, and would probably warrant a semver-major. Feel free to @ me for review if you go that route. |
Sorry, something went wrong.
|
@saghul Oh okay. I understood some parts of what you said, but I'm kinda new here(my first contribution), so could you please explain in a bit more detail(what 'handling' are you referring to?), or at least point me to some resources? Thanks 😄 . |
Sorry, something went wrong.
|
No problem Aayush. Right now the UDPWrap constructor cannot fail. It asserts that the return value of uv_udp_init is 0 here. Now, if you change it so the constructor gets the address family (AF_INET or AF_INET6) we would use uv_udp_init_ex, which creates the socket for the given family. This could fail if the system is out of file descriptors (UV_EMFILE) so the constructor would have to throw. Then that would mean that this line can throw, so that needs to be handled somehow. The problem I see is that dgram.createSocket doesn't take an errback, I guess because there was no way this could fail. As you can see, a few things would need to change. It's probably best to come up with a proposal before jumping in all the way, there might be dragons! :-) |
Sorry, something went wrong.
|
@saghul So, this is what I understood so far(please correct me if I'm wrong), I need to replace uv_udp_init from here, with uv_udp_init_ex having the necessary flags(AF_INET or AF_INET6) as documented here. One question: what does uv_udp_init_ex return when it succeeds(or fails)? Then, based on its return value, make a check here. |
Sorry, something went wrong.
It returns 0 on success or an UV error in case of failure. The rest is correct, but I'd wait for some more opinions before jumping in. |
Sorry, something went wrong.
|
Alright, cool. So, I'll wait for some time before diving in. Also, I have exams in 3 days, so I'll be inactive for a while. After that I'll be ready for whatever comes my way. |
Sorry, something went wrong.
|
@saghul Am I mistaken about the following analysis?:
Empirically, the test passes (on OS X, anyway) if you remove the bind() call. The output remains nearly identical. (PIDs change, of course.) |
Sorry, something went wrong.
|
@Trott calling uv_udp_set_ttl requires that the socket actually exists. When uv_udp_init is called the socket is not created, because we do that lazily. When uv_udp_init_ex is called with AF_INET or AF_INET6, the socket is created on the spot. If you call it with AF_UNSPEC it's the same as just doing uv_udp_init, that is, the socket is created lazily. So, if you call uv_udp_set_ttl before the socket is created you'll get UV_EBADF. Calling uv_udp_bind will create the socket if it wasn't created yet. Now, as I mentioned here, it seems like we already know the address family when creating the handle, hence my suggestion for switching to using uv_udp_init_ex. That however introduces a new point where an error could be produced (uv_udp_init can never fail) so it needs to be handled. |
Sorry, something went wrong.
|
@saghul So, if I'm understanding everything correctly, this would be the state of affairs:
|
Sorry, something went wrong.
|
@saghul Great! Thanks for your patience explaining this. Unless there's a reason not to, I'm going to give this PR an LGTM and open a separate issue to discuss/address the possibility of a generalized fix as you've outlined it here. |
Sorry, something went wrong.
|
@Trott thanks for opening the issue! As for this PR, does the test pass? I don't see how the socket can emit 'listening' without calling bind or any other function which causes an implicit one. |
Sorry, something went wrong.
|
@saghul It passes for me on OS X and the callback is definitely firing. I would expect an implicit .bind() via the subsequent .send(). |
Sorry, something went wrong.
|
Ah, right you are. LGTM. On Mon, Feb 29, 2016 at 11:04 PM, Rich Trott notifications@github.com
/Saúl |
Sorry, something went wrong.
Sorry, something went wrong.
|
One CI infrastructure problem, but CI is good other than that. |
Sorry, something went wrong.
As mentioned in the comment of the changed file, "a libuv limitation makes it necessary to bind()". But, that is not the case in this test. The subsequent call to send() results in an implicit bind(). PR-URL: nodejs#5023 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
As mentioned in the comment of the changed file, "a libuv limitation makes it necessary to bind()". But, that is not the case in this test. The subsequent call to send() results in an implicit bind(). PR-URL: #5023 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
As mentioned in the comment of the changed file, "a libuv limitation makes it necessary to bind()". But, that is not the case in this test. The subsequent call to send() results in an implicit bind(). PR-URL: #5023 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
As mentioned in the comment of the changed file, "a libuv limitation makes it necessary to bind()". But, that is not the case in this test. The subsequent call to send() results in an implicit bind(). PR-URL: #5023 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
| Back | FazBrowse Home | New Git URL |
Ref: #4640.
As mentioned in the above issue, some of the files have TODO, FIXME and XXX comments which should be removed. This is one of them. The comment(which is to be removed) says, "a libuv limitation makes it necessary to bind()". But, that is not the case any more. So, it can be removed.
/cc @Trott @Fishrock123