From 687d7ae894226eb0efeddc665fb079a41ea130e7 Mon Sep 17 00:00:00 2001 From: psychon Date: Sat, 30 Aug 2008 08:35:11 +0000 Subject: [PATCH] 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 --- znc.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/znc.h b/znc.h index 36d51ad6..d2e62f00 100644 --- a/znc.h +++ b/znc.h @@ -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 {