This repository has been archived by the owner on May 4, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unix: reimplement accept() EMFILE trick
Implement a best effort approach to mitigating accept() EMFILE errors. We have a spare file descriptor stashed away that we close to get below the EMFILE limit. Next, we accept all pending connections and close them immediately to signal the clients that we're overloaded - and we are, but we still keep on trucking. There is one caveat: it's not reliable in a multi-threaded environment. The file descriptor limit is per process. Our party trick fails if another thread opens a file or creates a socket in the time window between us calling close() and accept(). Fixes #315.
- Loading branch information
1 parent
86cb520
commit 4f5c8da
Showing
3 changed files
with
119 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters