-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Don't share dgram sockets that are implicitly bound #8643
Conversation
+1 |
👍 each commit is a one-liner + tests. |
@piscisaureus can you weigh in on this? Its particularly painful on windows, because cluster doesn't support sharing UPD on windows, so it causes "client" use of UDP to fail on windows with cluster. |
+1 |
Will fix #5587 if this lands. |
@sam-github Do tests pass on Windows (they weren't passing for #8642)? |
@greenboxal I could be a bit confused, because its not clear if you are commenting on #8642 or this PR, #8643. The only relationship is that the tests for dgram implicit binds being exclusive trigger a completely unrelated bug. I don't really care how that bug gets fixed, but if you have some thoughts, #8642 would be the place to comment. dgram sockets should NOT be shared at all, in the client use case (no bind). Currently, if worker A sends request x and worker B sends request y, worker B could get the response to x, and worker A the response to y. Or one could get both responses. This doesn't seem like a feature. Currently, if you create two dgram2 sockets in one worker, don't bind them, call .send() on both... they both end up with the same underlying shared handle/port! So they will also get intermingled responses. This doesn't seem like a feature either. Currently, dgram SharedHandles are _not supported at all_ on Windows, so dgram is completely unsupported with cluster on Windows. Attempts to use it, even in cases where its undesireable to share the socket at all, causes the node cluster master to die with ENOTSUP (in a way that is uncatchable...). This PR fixes the above three problems. dgram sockets that are explicitly bound are still allocated in the cluster master, even with this PR, causing the cluster master to die on Windows, but fixing that is much more than a one-liner. |
LGTM |
@sam-github I get this error when running
Other than that, it seems like a good change to me, provided that we take care of (potential) issues with #8642 first. I also think that we should land #8642 before looking at this one again, it will have the added benefit of making the change even smaller and avoid confusion when discussing it. |
@misterdjules check this out once #8642 lands, I have verified it on windows and linux, before and after the new behaviour for implictly bound sockets. |
@sam-github Thanks! I don't know if you got that on IRC, but I'm off until January 5th, so I probably won't have time to review it until then. |
@misterdjules Happy New Year! Do you have time to take a look at this? |
@sam-github Thanks, happy new year to you too :) I'm taking a look at #8642 first, and then I'll take a look at this one. #8642 looks good so far, and depending on where we are with the merge of v0.10 to v0.12, it'll land before or after it. How does that sound? |
@sam-github LGTM. This will land after #8642, so we'll need to rebase this branch at some point. Not landing until we know we're we stand regarding the ongoing merge of v0.10 into v0.12. Thanks! |
Adding it to the 0.11.15 milestone because it's been reviewed and tested, so it should be quick and easy to land. |
I'm happy to rebase, ping me when you want it. |
Server sockets should be shared by default, and client sockets should be exclusive by default. For net/TCP, this is how it is, for dgram/UDP, its a little less clear what a client socket is, but a socket that is auto-bound during a dgram.send() is not usefully shared among cluster workers, any more than an outgoing TCP connection would be usefully shared. Since implicit binds become exclusive, implicit/client dgram sockets can now be used with cluster on Windows. Before, neither explicit nor implicitly bound sockets could be used, causing dgram to be completely unsupported with cluster on Windows. After this change, they become half supported. PR-URL: nodejs/node-v0.x-archive#8643 Reviewed-by: Bert Belder <bertbelder@gmail.com>
lgtm, landed in io.js: nodejs/node@a32b92d |
The patch was reverted in io.js; nodejs/node#279 |
The patch was reverted because it makes test-cluster-dgram-2 fail. This test hangs because |
@piscisaureus Thanks for the heads-up! |
For shared handles that do not get connection close messages (UDP/dgram is the only example of this), cluster must not assume that a port listened on by one worker is listened on by all workers.
Workers that are already disconnected but not yet exited should not be disconnected, trying to do so raises exceptions.
Server sockets should be shared by default, and client sockets should be exclusive by default. For net/TCP, this is how it is, for dgram/UDP, its a little less clear what a client socket is, but a socket that is auto-bound during a dgram.send() is not usefully shared among cluster workers, any more than an outgoing TCP connection would be usefully shared. Since implicit binds become exclusive, implicit/client dgram sockets can now be used with cluster on Windows. Before, neither explicit nor implicitly bound sockets could be used, causing dgram to be completely unsupported with cluster on Windows. After this change, they become half supported.
Server sockets should be shared by default, and client sockets should be exclusive by default. For net/TCP, this is how it is, for dgram/UDP, its a little less clear what a client socket is, but a socket that is auto-bound during a dgram.send() is not usefully shared among cluster workers, any more than an outgoing TCP connection would be usefully shared. Since implicit binds become exclusive, implicit/client dgram sockets can now be used with cluster on Windows. Before, neither explicit nor implicitly bound sockets could be used, causing dgram to be completely unsupported with cluster on Windows. After this change, they become half supported. PR-URL: nodejs/node-v0.x-archive#8643 Reviewed-by: Bert Belder <bertbelder@gmail.com>
Fixed in 0b827a0 |
cf. nodejs/node#325 |
Server sockets should be shared by default, and client sockets should be exclusive by default. For net/TCP, this is how it is, for dgram/UDP, its a little less clear what a client socket is, but a socket that is auto-bound during a dgram.send() is not usefully shared among cluster workers, any more than an outgoing TCP connection would be usefully shared. Since implicit binds become exclusive, implicit/client dgram sockets can now be used with cluster on Windows. Before, neither explicit nor implicitly bound sockets could be used, causing dgram to be completely unsupported with cluster on Windows. After this change, they become half supported. PR-URL: nodejs/node-v0.x-archive#8643 Reviewed-by: Bert Belder <bertbelder@gmail.com>
Server sockets should be shared by default, and client sockets should be exclusive by default. For net/TCP, this is how it is, for dgram/UDP, its a little less clear what a client socket is, but a socket that is auto-bound during a dgram.send() is not usefully shared among cluster workers, any more than an outgoing TCP connection would be usefully shared. Since implicit binds become exclusive, implicit/client dgram sockets can now be used with cluster on Windows. Before, neither explicit nor implicitly bound sockets could be used, causing dgram to be completely unsupported with cluster on Windows. After this change, they become half supported. PR: #325 PR: nodejs/node-v0.x-archive#8643 Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-by: Bert Belder <bertbelder@gmail.com>
@tjfontaine @trevnorris @cjihrig @orangemocha OK to land nodejs/node#325 (the fixed version of this PR) in master? |
+1 from me |
@cjihrig @trevnorris Thanks! Will land it asap. |
Server sockets should be shared by default, and client sockets should be exclusive by default. For net/TCP, this is how it is, for dgram/UDP, its a little less clear what a client socket is, but a socket that is auto-bound during a dgram.send() is not usefully shared among cluster workers, any more than an outgoing TCP connection would be usefully shared. Since implicit binds become exclusive, implicit/client dgram sockets can now be used with cluster on Windows. Before, neither explicit nor implicitly bound sockets could be used, causing dgram to be completely unsupported with cluster on Windows. After this change, they become half supported. PR: nodejs#8643 Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-by: Bert Belder <bertbelder@gmail.com> Reviewed-by: Julien Gilli <julien.gilli@joyent.com>
Server sockets should be shared by default, and client sockets should be exclusive by default. For net/TCP, this is how it is, for dgram/UDP, its a little less clear what a client socket is, but a socket that is auto-bound during a dgram.send() is not usefully shared among cluster workers, any more than an outgoing TCP connection would be usefully shared. Since implicit binds become exclusive, implicit/client dgram sockets can now be used with cluster on Windows. Before, neither explicit nor implicitly bound sockets could be used, causing dgram to be completely unsupported with cluster on Windows. After this change, they become half supported. PR: #8643 Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-by: Bert Belder <bertbelder@gmail.com> Reviewed-by: Julien Gilli <julien.gilli@joyent.com>
Landed in e42c4a3. Thanks again @sam-github! |
... otherwise it doesn't play nicely with cluster. Similar: nodejs/node-v0.x-archive#8643
Server sockets should be shared by default, and client sockets should be exclusive by default. For net/TCP, this is how it is, for dgram/UDP, its a little less clear what a client socket is, but a socket that is auto-bound during a dgram.send() is not usefully shared among cluster workers, any more than an outgoing TCP connection would be usefully shared. Since implicit binds become exclusive, implicit/client dgram sockets can now be used with cluster on Windows. Before, neither explicit nor implicitly bound sockets could be used, causing dgram to be completely unsupported with cluster on Windows. After this change, they become half supported. PR: nodejs#8643 Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-by: Bert Belder <bertbelder@gmail.com> Reviewed-by: Julien Gilli <julien.gilli@joyent.com>
Server sockets should be shared by default, and client sockets should be
exclusive by default. For net/TCP, this is how it is, for dgram/UDP, its
a little less clear what a client socket is, but a socket that is
auto-bound during a dgram.send() is not usefully shared among cluster
workers, any more than an outgoing TCP connection would be usefully
shared.
See #8027 (comment)
/to @asilvas @bnoordhuis @rmg
Test triggers a pre-existing bug, so is based on #8642.