Bug fixes for script function calls.

This commit is contained in:
Gunnar Beutner 2013-02-15 05:04:38 +01:00
parent 2485a04694
commit 2faca52744
4 changed files with 11 additions and 9 deletions

View File

@ -72,16 +72,18 @@ void ScriptInterpreter::ThreadWorkerProc(void)
ScriptCall call = m_Calls.front(); ScriptCall call = m_Calls.front();
m_Calls.pop_front(); m_Calls.pop_front();
ProcessCall(call.Task, call.Function, call.Arguments);
} }
} }
void ScriptInterpreter::ScriptFunctionThunk(const ScriptTask::Ptr& task, void ScriptInterpreter::ScriptFunctionThunk(const ScriptTask::Ptr& task,
const vector<Value>& arguments, const String& function) const String& function, const vector<Value>& arguments)
{ {
ScriptCall call; ScriptCall call;
call.Task = task;
call.Function = function; call.Function = function;
call.Arguments = arguments; call.Arguments = arguments;
call.Task = task;
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(m_Mutex);
@ -96,7 +98,7 @@ void ScriptInterpreter::SubscribeFunction(const String& name)
m_SubscribedFunctions.insert(name); m_SubscribedFunctions.insert(name);
ScriptFunction::Ptr sf = boost::make_shared<ScriptFunction>(boost::bind(&ScriptInterpreter::ScriptFunctionThunk, this, _1, _2, name)); ScriptFunction::Ptr sf = boost::make_shared<ScriptFunction>(boost::bind(&ScriptInterpreter::ScriptFunctionThunk, this, _1, name, _2));
ScriptFunction::Register(name, sf); ScriptFunction::Register(name, sf);
} }

View File

@ -25,9 +25,9 @@ namespace icinga
struct ScriptCall struct ScriptCall
{ {
ScriptTask::Ptr Task;
String Function; String Function;
vector<Value> Arguments; vector<Value> Arguments;
ScriptTask::Ptr Task;
}; };
/** /**
@ -49,7 +49,7 @@ public:
protected: protected:
ScriptInterpreter(const Script::Ptr& script); ScriptInterpreter(const Script::Ptr& script);
virtual void ProcessCall(const String& function, const ScriptTask::Ptr& task, virtual void ProcessCall(const ScriptTask::Ptr& task, const String& function,
const vector<Value>& arguments) = 0; const vector<Value>& arguments) = 0;
void SubscribeFunction(const String& name); void SubscribeFunction(const String& name);
@ -67,8 +67,8 @@ private:
void ThreadWorkerProc(void); void ThreadWorkerProc(void);
void ScriptFunctionThunk(const ScriptTask::Ptr& task, void ScriptFunctionThunk(const ScriptTask::Ptr& task, const String& function,
const vector<Value>& arguments, const String& function); const vector<Value>& arguments);
}; };
} }

View File

@ -66,7 +66,7 @@ void PythonInterpreter::UnregisterFunction(const String& name)
m_Functions.erase(name); m_Functions.erase(name);
} }
void PythonInterpreter::ProcessCall(const String& function, const ScriptTask::Ptr& task, void PythonInterpreter::ProcessCall(const ScriptTask::Ptr& task, const String& function,
const vector<Value>& arguments) const vector<Value>& arguments)
{ {
PyEval_AcquireThread(m_ThreadState); PyEval_AcquireThread(m_ThreadState);

View File

@ -45,7 +45,7 @@ protected:
PyThreadState *m_ThreadState; PyThreadState *m_ThreadState;
map<String, PyObject *> m_Functions; map<String, PyObject *> m_Functions;
virtual void ProcessCall(const String& function, const ScriptTask::Ptr& task, virtual void ProcessCall(const ScriptTask::Ptr& task, const String& function,
const vector<Value>& arguments); const vector<Value>& arguments);
}; };