Remove sockets and timers from perl modules in their destructors.

This should decrease memory usage a bit, and decrease chance of crashing znc from bad perl module a bit.

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2156 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
darthgandalf
2010-10-10 09:59:15 +00:00
parent 8a690170e3
commit 9c2692f1f1
3 changed files with 48 additions and 0 deletions
+20
View File
@@ -249,6 +249,17 @@ void CPerlTimer::RunJob() {
}
}
CPerlTimer::~CPerlTimer() {
CPerlModule* pMod = AsPerlModule(GetModule());
if (pMod) {
PSTART;
PUSH_STR(pMod->GetPerlID());
PUSH_STR(GetPerlID());
PCALL("ZNC::Core::RemoveTimer");
PEND;
}
}
#define SOCKSTART PSTART; PUSH_STR(pMod->GetPerlID()); PUSH_STR(GetPerlID())
#define SOCKCBCHECK(OnSuccess) PCALL("ZNC::Core::CallSocket"); if (SvTRUE(ERRSV)) { Close(); DEBUG("Perl socket hook died with: " + PString(ERRSV)); } else { OnSuccess; } PEND
#define CBSOCK(Func) void CPerlSocket::Func() {\
@@ -298,4 +309,13 @@ Csock* CPerlSocket::GetSockObj(const CString& sHost, unsigned short uPort) {
return result;
}
CPerlSocket::~CPerlSocket() {
CPerlModule* pMod = AsPerlModule(GetModule());
if (pMod) {
SOCKSTART;
PCALL("ZNC::Core::RemoveSocket");
PEND;
}
}
GLOBALMODULEDEFS(CModPerl, "Loads perl scripts as ZNC modules")