[sr-dev] git:master:3afb9659: app_python: ensure cfg framework is initialized for child init callback

Daniel-Constantin Mierla miconda at gmail.com
Tue Aug 14 11:06:31 CEST 2018


Module: kamailio
Branch: master
Commit: 3afb9659ab8b25ff8cfbe4fc706396b83db51021
URL: https://github.com/kamailio/kamailio/commit/3afb9659ab8b25ff8cfbe4fc706396b83db51021

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-08-14T11:05:17+02:00

app_python: ensure cfg framework is initialized for child init callback

- reported by GH #1618

---

Modified: src/modules/app_python/app_python_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/3afb9659ab8b25ff8cfbe4fc706396b83db51021.diff
Patch: https://github.com/kamailio/kamailio/commit/3afb9659ab8b25ff8cfbe4fc706396b83db51021.patch

---

diff --git a/src/modules/app_python/app_python_mod.c b/src/modules/app_python/app_python_mod.c
index 5c5278f42d..8ed21e1c93 100644
--- a/src/modules/app_python/app_python_mod.c
+++ b/src/modules/app_python/app_python_mod.c
@@ -26,6 +26,7 @@
 #include "../../core/sr_module.h"
 #include "../../core/mod_fix.h"
 #include "../../core/kemi.h"
+#include "../../core/cfg/cfg_struct.h"
 
 #include "python_exec.h"
 #include "python_iface.h"
@@ -278,7 +279,7 @@ int apy_mod_init(PyObject *pModule)
 	Py_XDECREF(_sr_apy_handler_obj);
 	_sr_apy_handler_obj = pHandler;
 	rval = 0;
- err:
+err:
 	return rval;
 }
 
@@ -291,7 +292,7 @@ int apy_reload_script(void)
 	PY_GIL_ENSURE;
 	pModule = PyImport_ReloadModule(_sr_apy_module);
 	if (!pModule) {
-                // PyErr_PrintEx(0); - don't hide the real exception
+		// PyErr_PrintEx(0); - don't hide the real exception
 		if (!PyErr_Occurred())
 			PyErr_Format(PyExc_ImportError, "Reload module '%s'", bname);
 		python_handle_exception("mod_init");
@@ -306,15 +307,15 @@ int apy_reload_script(void)
 	Py_DECREF(_sr_apy_module);
 	_sr_apy_module = pModule;
 
-        if(apy_init_script(_apy_process_rank)<0) {
-                LM_ERR("failed to init script\n");
+	if(apy_init_script(_apy_process_rank)<0) {
+		LM_ERR("failed to init script\n");
 		goto err;
-        }
+	}
 
 	rval = 0;
- err:
+err:
 	PY_GIL_RELEASE;
-        return rval;
+	return rval;
 }
 
 int apy_load_script(void)
@@ -390,7 +391,7 @@ int apy_load_script(void)
 	_sr_apy_module = pModule;
 
 	rval = apy_mod_init(pModule);
- err:
+err:
 	PY_GIL_RELEASE;
 	return rval;
 }
@@ -435,6 +436,10 @@ int apy_init_script(int rank)
 		goto err;
 	}
 
+	if (cfg_child_init()) {
+		goto err;
+	}
+
 	pArgs = PyTuple_New(1);
 	if (pArgs == NULL) {
 		python_handle_exception("child_init");
@@ -485,7 +490,7 @@ int apy_init_script(int rank)
 	rval = PyInt_AsLong(pResult);
 	Py_DECREF(pResult);
 
- err:
+err:
 	PY_GIL_RELEASE;
 	return rval;
 }




More information about the sr-dev mailing list