From 0f0463510c0a3bbd66ca1161d244fe7f25a3708a Mon Sep 17 00:00:00 2001 From: psychon Date: Thu, 29 Jan 2009 19:11:53 +0000 Subject: [PATCH] Some fixes to modperl, most notable no with time increasing memory usage Because some ENTER/LEAVE pair was missing, the stack perl uses for passing arguments grew and grew. Besides adding those calls this also fixes some more of the callback calling code to look a little closer to the examples from perldoc. This also fixes some warnings perl threw at us when unloading by not making ZNC::{CONTINUE,HALT{,MODS,CORE}} mortal. Thanks to tomaw and AnMaster for reporting and helping me debug this mem issue. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1357 726aef4b-f618-498e-8847-2d620e286838 --- modules/modperl.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/modperl.cpp b/modules/modperl.cpp index ab922de4..a8ab4ce8 100644 --- a/modules/modperl.cpp +++ b/modules/modperl.cpp @@ -926,6 +926,7 @@ CModPerl::EModRet CModPerl::CallBack(const PString & sHookName, const VPString & return(CONTINUE); dSP; + ENTER; SAVETMPS; PUSHMARK(SP); @@ -957,7 +958,7 @@ CModPerl::EModRet CModPerl::CallBack(const PString & sHookName, const VPString & PUTBACK; - int iCount = call_pv(sFuncToCall.c_str(), G_EVAL|G_SCALAR); + int iCount = call_pv(sFuncToCall.c_str(), G_EVAL|G_SCALAR|G_KEEPERR); SPAGAIN; int iRet = CONTINUE; @@ -969,6 +970,7 @@ CModPerl::EModRet CModPerl::CallBack(const PString & sHookName, const VPString & if (eCBType == CB_TIMER) iRet = HALT; + POPs; } else { if (iCount == 1) @@ -977,6 +979,7 @@ CModPerl::EModRet CModPerl::CallBack(const PString & sHookName, const VPString & PUTBACK; FREETMPS; + LEAVE; return((CModPerl::EModRet)iRet); } @@ -1039,10 +1042,10 @@ bool CModPerl::OnLoad(const CString & sArgs, CString & sMessage) sv_2mortal((SV*)pZNCSpace); - newCONSTSUB(pZNCSpace, "CONTINUE", PString(CONTINUE).GetSV()); - newCONSTSUB(pZNCSpace, "HALT", PString(HALT).GetSV()); - newCONSTSUB(pZNCSpace, "HALTMODS", PString(HALTMODS).GetSV()); - newCONSTSUB(pZNCSpace, "HALTCORE", PString(HALTCORE).GetSV()); + newCONSTSUB(pZNCSpace, "CONTINUE", PString(CONTINUE).GetSV(false)); + newCONSTSUB(pZNCSpace, "HALT", PString(HALT).GetSV(false)); + newCONSTSUB(pZNCSpace, "HALTMODS", PString(HALTMODS).GetSV(false)); + newCONSTSUB(pZNCSpace, "HALTCORE", PString(HALTCORE).GetSV(false)); return(true); }