[icinga-checkins] icinga.org: icinga2/master: Bug fixes for script function calls.

git at icinga.org git at icinga.org
Fri Feb 15 09:48:12 CET 2013


Module: icinga2
Branch: master
Commit: 2faca52744361f458dd56065d5061d0f1fd6dc63
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=2faca52744361f458dd56065d5061d0f1fd6dc63

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Fri Feb 15 05:04:38 2013 +0100

Bug fixes for script function calls.

---

 lib/base/scriptinterpreter.cpp   |    8 +++++---
 lib/base/scriptinterpreter.h     |    8 ++++----
 lib/python/pythoninterpreter.cpp |    2 +-
 lib/python/pythoninterpreter.h   |    2 +-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/lib/base/scriptinterpreter.cpp b/lib/base/scriptinterpreter.cpp
index 6106560..b1ae0b3 100644
--- a/lib/base/scriptinterpreter.cpp
+++ b/lib/base/scriptinterpreter.cpp
@@ -72,16 +72,18 @@ void ScriptInterpreter::ThreadWorkerProc(void)
 
 		ScriptCall call = m_Calls.front();
 		m_Calls.pop_front();
+
+		ProcessCall(call.Task, call.Function, call.Arguments);
 	}
 }
 
 void ScriptInterpreter::ScriptFunctionThunk(const ScriptTask::Ptr& task,
-    const vector<Value>& arguments, const String& function)
+    const String& function, const vector<Value>& arguments)
 {
 	ScriptCall call;
+	call.Task = task;
 	call.Function = function;
 	call.Arguments = arguments;
-	call.Task = task;
 
 	{
 		boost::mutex::scoped_lock lock(m_Mutex);
@@ -96,7 +98,7 @@ void ScriptInterpreter::SubscribeFunction(const String& 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);
 }
 
diff --git a/lib/base/scriptinterpreter.h b/lib/base/scriptinterpreter.h
index e7f22b2..74f0014 100644
--- a/lib/base/scriptinterpreter.h
+++ b/lib/base/scriptinterpreter.h
@@ -25,9 +25,9 @@ namespace icinga
 
 struct ScriptCall
 {
+	ScriptTask::Ptr Task;
 	String Function;
 	vector<Value> Arguments;
-	ScriptTask::Ptr Task;
 };
 
 /**
@@ -49,7 +49,7 @@ public:
 protected:
 	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;
 
 	void SubscribeFunction(const String& name);
@@ -67,8 +67,8 @@ private:
 
 	void ThreadWorkerProc(void);
 
-	void ScriptFunctionThunk(const ScriptTask::Ptr& task,
-	    const vector<Value>& arguments, const String& function);
+	void ScriptFunctionThunk(const ScriptTask::Ptr& task, const String& function,
+	    const vector<Value>& arguments);
 };
 
 }
diff --git a/lib/python/pythoninterpreter.cpp b/lib/python/pythoninterpreter.cpp
index 4c48735..d4275c7 100644
--- a/lib/python/pythoninterpreter.cpp
+++ b/lib/python/pythoninterpreter.cpp
@@ -66,7 +66,7 @@ void PythonInterpreter::UnregisterFunction(const String& 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)
 {
 	PyEval_AcquireThread(m_ThreadState);
diff --git a/lib/python/pythoninterpreter.h b/lib/python/pythoninterpreter.h
index 73892c2..07cc832 100644
--- a/lib/python/pythoninterpreter.h
+++ b/lib/python/pythoninterpreter.h
@@ -45,7 +45,7 @@ protected:
 	PyThreadState *m_ThreadState;
 	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);
 };
 





More information about the icinga-checkins mailing list