]> jfr.im git - irc/rizon/znc.git/commitdiff
Close listening ports if we have too many open fds
authorpsychon <redacted>
Sat, 30 Aug 2008 08:35:11 +0000 (08:35 +0000)
committerpsychon <redacted>
Sat, 30 Aug 2008 08:35:11 +0000 (08:35 +0000)
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

diff --git a/znc.h b/znc.h
index 36d51ad6ecb9ab180514e19737776be4c9f78389..d2e62f004b14df2c7ac06596aaa2848938fc7fe0 100644 (file)
--- 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 {