retry if accept fails because of too many files

This commit is contained in:
Arvid Norberg 2010-03-09 17:50:10 +00:00
parent a3bff512e1
commit 06cca08afd
1 changed files with 11 additions and 0 deletions

View File

@ -1553,6 +1553,17 @@ namespace aux {
return;
}
#endif
if (e == boost::system::errc::too_many_files_open)
{
// if we failed to accept an incoming connection
// because we have too many files open, try again
// and lower the number of file descriptors used
// elsewere.
if (m_max_connections > 10)
--m_max_connections;
// try again, but still alert the user of the problem
async_accept(listener);
}
if (m_alerts.should_post<listen_failed_alert>())
m_alerts.post_alert(listen_failed_alert(ep, e));
return;