Ver código fonte

app_python: ensure cfg framework is initialized for child init callback

- reported by GH #1618
Daniel-Constantin Mierla 7 anos atrás
pai
commit
3afb9659ab
1 arquivos alterados com 14 adições e 9 exclusões
  1. 14 9
      src/modules/app_python/app_python_mod.c

+ 14 - 9
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;
 }