4 ms·
I had this problem, and I solved it by farming the known-blocking syscalls to a separate thread pool. Then the calling thread can just abandon the wait. To make
by cyberax 1y ago
I had this problem, and I solved it by farming the known-blocking syscalls to a separate thread pool. Then the calling thread can just abandon the wait. To make it a bit better, you can also use bounded timeouts (~1-2 seconds) with retries for some calls like recvfrom() via SO_TIMEOUT so that the termination time becomes bounded.
This is probably the cleanest solution that is portable.
- naasking 1y agoThen those thread pool threads have to be careful not to take locks and other scarce resources that aren't cleaned up then, no?
- cyberax 1y agoSure. But if you only use it to run blocking requests, it's probably going to be pretty trivial. It won't be super-high performance because of all the cache bounces, but if you're not using something like epoll, then you probably are not really focused on performance anyway.