fixed a serious bug where deleted forwards could be placed in the re-use cache too soon
This commit is contained in:
parent
3e0866e57a
commit
c15a23a2a7
@ -226,6 +226,8 @@ void CSPForward::Set(int func, AMX *amx, int numParams, const ForwardParam *para
|
|||||||
name[0] = '\0';
|
name[0] = '\0';
|
||||||
amx_GetPublic(amx, func, name);
|
amx_GetPublic(amx, func, name);
|
||||||
m_Name.assign(name);
|
m_Name.assign(name);
|
||||||
|
m_ToDelete = false;
|
||||||
|
m_InExec = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSPForward::Set(const char *funcName, AMX *amx, int numParams, const ForwardParam *paramTypes)
|
void CSPForward::Set(const char *funcName, AMX *amx, int numParams, const ForwardParam *paramTypes)
|
||||||
@ -236,6 +238,8 @@ void CSPForward::Set(const char *funcName, AMX *amx, int numParams, const Forwar
|
|||||||
m_HasFunc = (amx_FindPublic(amx, funcName, &m_Func) == AMX_ERR_NONE);
|
m_HasFunc = (amx_FindPublic(amx, funcName, &m_Func) == AMX_ERR_NONE);
|
||||||
isFree = false;
|
isFree = false;
|
||||||
m_Name.assign(funcName);
|
m_Name.assign(funcName);
|
||||||
|
m_ToDelete = false;
|
||||||
|
m_InExec = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
||||||
@ -248,13 +252,15 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
cell realParams[FORWARD_MAX_PARAMS];
|
cell realParams[FORWARD_MAX_PARAMS];
|
||||||
cell *physAddrs[FORWARD_MAX_PARAMS];
|
cell *physAddrs[FORWARD_MAX_PARAMS];
|
||||||
|
|
||||||
if (!m_HasFunc)
|
if (!m_HasFunc || m_ToDelete)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CPluginMngr::CPlugin *pPlugin = g_plugins.findPluginFast(m_Amx);
|
CPluginMngr::CPlugin *pPlugin = g_plugins.findPluginFast(m_Amx);
|
||||||
if (!pPlugin->isExecutable(m_Func))
|
if (!pPlugin->isExecutable(m_Func))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
m_InExec = true;
|
||||||
|
|
||||||
Debugger *pDebugger = (Debugger *)m_Amx->userdata[UD_DEBUGGER];
|
Debugger *pDebugger = (Debugger *)m_Amx->userdata[UD_DEBUGGER];
|
||||||
if (pDebugger)
|
if (pDebugger)
|
||||||
pDebugger->BeginExec();
|
pDebugger->BeginExec();
|
||||||
@ -356,6 +362,8 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_InExec = false;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,7 +460,20 @@ bool CForwardMngr::isIdValid(int id) const
|
|||||||
|
|
||||||
cell CForwardMngr::executeForwards(int id, cell *params)
|
cell CForwardMngr::executeForwards(int id, cell *params)
|
||||||
{
|
{
|
||||||
int retVal = (id & 1) ? m_SPForwards[id >> 1]->execute(params, m_TmpArrays) : m_Forwards[id >> 1]->execute(params, m_TmpArrays);
|
int retVal;
|
||||||
|
if (id & 1)
|
||||||
|
{
|
||||||
|
CSPForward *fwd = m_SPForwards[id >> 1];
|
||||||
|
retVal = fwd->execute(params, m_TmpArrays);
|
||||||
|
if (fwd->m_ToDelete)
|
||||||
|
{
|
||||||
|
fwd->m_ToDelete = false;
|
||||||
|
unregisterSPForward(id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
retVal = m_Forwards[id >> 1]->execute(params, m_TmpArrays);
|
||||||
|
}
|
||||||
|
|
||||||
m_TmpArraysNum = 0;
|
m_TmpArraysNum = 0;
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
@ -524,9 +545,16 @@ void CForwardMngr::unregisterSPForward(int id)
|
|||||||
if (!isIdValid(id) || m_SPForwards.at(id >> 1)->isFree)
|
if (!isIdValid(id) || m_SPForwards.at(id >> 1)->isFree)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_SPForwards.at(id >> 1)->isFree = true;
|
CSPForward *fwd = m_SPForwards.at(id >> 1);
|
||||||
|
|
||||||
|
if (fwd->m_InExec)
|
||||||
|
{
|
||||||
|
fwd->m_ToDelete = true;
|
||||||
|
} else {
|
||||||
|
fwd->isFree = true;
|
||||||
m_FreeSPForwards.push(id);
|
m_FreeSPForwards.push(id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int registerForwardC(const char *funcName, ForwardExecType et, cell *list, size_t num, int fwd_type)
|
int registerForwardC(const char *funcName, ForwardExecType et, cell *list, size_t num, int fwd_type)
|
||||||
{
|
{
|
||||||
|
@ -143,6 +143,7 @@ public:
|
|||||||
// Single plugin forward
|
// Single plugin forward
|
||||||
class CSPForward
|
class CSPForward
|
||||||
{
|
{
|
||||||
|
friend class CForwardMngr;
|
||||||
const char *m_FuncName;
|
const char *m_FuncName;
|
||||||
int m_NumParams;
|
int m_NumParams;
|
||||||
|
|
||||||
@ -152,6 +153,8 @@ class CSPForward
|
|||||||
int m_Func;
|
int m_Func;
|
||||||
bool m_HasFunc;
|
bool m_HasFunc;
|
||||||
String m_Name;
|
String m_Name;
|
||||||
|
bool m_InExec;
|
||||||
|
bool m_ToDelete;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isFree;
|
bool isFree;
|
||||||
|
Loading…
Reference in New Issue
Block a user