-
Notifications
You must be signed in to change notification settings - Fork 635
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
Adding support for bind before connect. #140
base: master
Are you sure you want to change the base?
Adding support for bind before connect. #140
Conversation
I understand the problem you are trying to solve. Is there any reason why this can't be solved without modifying LuaSocket? For example, you can use the "create" field in the request table to give you complete control over the socket object. You can, for example, return a socket that is already bound. |
I think I can do it via the optional create function. I thought it would be nice for others, as its a non-trivial scenario to debug (need high load on a machine with a very fast network to the http server). But if you are not interested in it, then I can close this PR. |
I am definitely interested in the issue, as it is not something I had considered before. The use case for the "create" field has always been non-blocking I/O, as per the "check-links.lua" program in etc/. It would be nice to see if it can be used to solve your problem as well. I believe it would. In fact, there is a pull request I am ashamed not to have gone through yet that would simplify this even further, by factoring out and exposing the url parsing that goes on to create the request table from the url. I tend to prefer general solutions to specific ones. |
Thanks, yeah, understood, my goal was just to provide future users with an On Thu, May 28, 2015 at 9:40 AM, Diego Nehab [email protected]
|
Certainly. It will look even better once I merge the factoring of url parsing. |
Did we reach an agreement here? |
Does using We're reviewing open items in preparation for a release. If action is needed here, please add a comment. Otherwise, this issue will be closed on or after 24-Feb-2019. Thanks! |
We use http to get 1000s of files per second and maintain that rate for hours. This leaves a lot of sockets in the TIME_WAIT state and will eventually cause the kernel to run out of ephemeral ports to assign. The solution is to bind before connect and keep trying to do so until an ephemeral port is found.
You can read about the solution here
https://idea.popcount.org/2014-04-03-bind-before-connect/
This is a very hard condition to unit test, but we test it empirically all the time. Thanks!