mirror of
https://github.com/znc/znc.git
synced 2026-08-07 09:22:55 +02:00
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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user