-
Notifications
You must be signed in to change notification settings - Fork 261
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
busy loop on too many open files #1003
Comments
@domenkozar I do not follow that: When acceptLoop = do
mx <- acceptNewConnection
case mx of
Nothing -> return ()
Just (mkConn, addr) -> do
fork set mkConn addr app counter ii
acceptLoop I can't see a place where " The whole code is (irrelevant lines removed): acceptConnection set getConnMaker app counter ii = do
void $ UnliftIO.mask_ acceptLoop
where
acceptLoop = do
mx <- acceptNewConnection
case mx of
Nothing -> return ()
Just (mkConn, addr) -> do
fork set mkConn addr app counter ii
acceptLoop
acceptNewConnection = do
ex <- UnliftIO.tryIO getConnMaker
case ex of
Right x -> return $ Just x
Left e -> do
let eConnAborted = getErrno eCONNABORTED
getErrno (Errno cInt) = cInt
if ioe_errno e == Just eConnAborted
then acceptNewConnection
else do
settingsOnException set Nothing $ toException e
return Nothing |
@nh2 good catch, thank you! I've pushed a fix to the PR that adds a delay before retrying with a new connection. |
The issue is that this function only checks for the
eCONNABORTED
error specifically. If any other error occurs, including a "too many open files" error, it will callsettingsOnException
and then returnNothing
, which causesacceptLoop
to exit.However,
acceptLoop
is called in a loop fromacceptConnection
, so it will immediately try to accept a new connection again. If the "too many open files" error persists, this will result in a busy loop, constantly trying to accept new connections and failing.To fix this, you could:
eCONNABORTED
.The text was updated successfully, but these errors were encountered: