Module: kamailio
Branch: master
Commit: d2c22d2b72d7ffd616a6aaacbabc6184a8da56e7
URL:
https://github.com/kamailio/kamailio/commit/d2c22d2b72d7ffd616a6aaacbabc618…
Author: Anthony Alba <ascanio.alba7(a)gmail.com>
Committer: Anthony Alba <ascanio.alba7(a)gmail.com>
Date: 2021-11-22T11:46:25+08:00
app_python3: Python >= 3.7 call PyOS_AfterFork_Parent in main context after all forks
---
Modified: src/modules/app_python3/app_python3_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/d2c22d2b72d7ffd616a6aaacbabc618…
Patch:
https://github.com/kamailio/kamailio/commit/d2c22d2b72d7ffd616a6aaacbabc618…
---
diff --git a/src/modules/app_python3/app_python3_mod.c
b/src/modules/app_python3/app_python3_mod.c
index 8ec252039c..f710694d75 100644
--- a/src/modules/app_python3/app_python3_mod.c
+++ b/src/modules/app_python3/app_python3_mod.c
@@ -104,7 +104,13 @@ static int mod_init(void)
char *dname_src, *bname_src;
int i;
- if(apy_sr_init_mod()<0) {
+ /*
+ * register the need to be called post-fork of all children
+ * with the special rank PROC_POSTCHILDINIT
+ */
+ ksr_module_set_flag(KSRMOD_FLAG_POSTCHILDINIT);
+
+ if (apy_sr_init_mod()<0) {
LM_ERR("failed to init the sr mod\n");
return -1;
}
@@ -185,6 +191,16 @@ static int child_init(int rank)
*/
#if PY_VERSION_HEX >= 0x03070000
PyOS_BeforeFork() ;
+#endif
+ return 0;
+ }
+ if(rank==PROC_POSTCHILDINIT) {
+ /*
+ * this is called after forking of all child
+ * processes
+ */
+#if PY_VERSION_HEX >= 0x03070000
+ PyOS_AfterFork_Parent() ;
#endif
return 0;
}