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
Panic when out of file descriptors #195
Comments
Some elaboration of why this is done this way below. |
Are you having the issue where a It would be useful if you could capture the above error with a full backtrace, but my suspicion is it's coming from the acceptor thread that dispatches to the worker pool. Handling this situation is interesting, if the acceptor thread has run out of FDs, there's not a lot we can do with it. We need to use |
FWIW, panic is also the results if the limit on threads is hit. As a consequence of the panic, a Mutex is poisoned, and recovery is pretty much impossible, AFAICT. Feb 08 00:47:23: thread '' panicked at 'failed to spawn thread: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }', /rustc/db9d1b20bba1968c1ec1fc49616d474> |
Not sure what is the right approach to fix this. For me I typically use |
Added tests for the two different scenarios of "Out of file-handles" and "Out of threads" to a draft PR. #219 |
@bradfier Sorry, I realized first now I didn't exactly answer the question. The problem with how tiny-http works right now IMO, is that the internal Mutex is poisoned, and never recovers. That means that if the service temporarily hits too many concurrent connections, not only are the "overflowing" connections rejected, but the service is left permanently in a defunctional state. I.E. even if all other connections disconnect, the service will no longer accept new connections either. This is what I tried to cover with the drafted test-cases. They start a server in a subprocess, arbitrarily confined with narrow resource-limits. The tests then make sure to hit those limits, ( I've clean up the tests a little bit to better illustrate. |
https://github.com/tiny-http/tiny-http/blob/master/src/util/refined_tcp_stream.rs#L45 can panic when there are no available file descriptors.
Rather than panic an error should be returned, so that the calling code can decide on the best course of action.
The text was updated successfully, but these errors were encountered: