Close listening ports if we have too many open fds

The alternative to this is a busy loop which is a Bad Idea (tm).
Next rehash will reopen the port anyway, so meh, this is the best we can do.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1180 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-08-30 08:35:11 +00:00
parent 69f44c35a0
commit 687d7ae894

9
znc.h
View File

@@ -236,6 +236,15 @@ public:
virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort) {
return new CClient(sHost, uPort);
}
virtual void SockError(int iErrno) {
DEBUG_ONLY(cout << GetSockName() << " == SockError(" << strerror(iErrno) << ")" << endl);
if (iErrno == EMFILE) {
// We have too many open fds, let's close this listening port to be able to continue
// to work, next rehash will (try to) reopen it.
Close();
}
}
};
class CListener {