[sr-dev] git:5.6:1dfca366: app_python3: call PyOS_AfterFork_Child() only in child processes

Anthony Alba ascanio.alba7 at gmail.com
Thu Jun 9 18:07:05 CEST 2022


Module: kamailio
Branch: 5.6
Commit: 1dfca366a8eb781bfd178e01378d2f7333c67956
URL: https://github.com/kamailio/kamailio/commit/1dfca366a8eb781bfd178e01378d2f7333c67956

Author: Anthony Alba <ascanio.alba7 at gmail.com>
Committer: Anthony Alba <ascanio.alba7 at gmail.com>
Date: 2022-06-10T00:02:02+08:00

app_python3: call PyOS_AfterFork_Child() only in child processes

- GH #3125: we should not call PyOS_AfterFork_Child() in the main
process.

(cherry picked from commit 69b4b6222e)

---

Modified: src/modules/app_python3/app_python3_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/1dfca366a8eb781bfd178e01378d2f7333c67956.diff
Patch: https://github.com/kamailio/kamailio/commit/1dfca366a8eb781bfd178e01378d2f7333c67956.patch

---

diff --git a/src/modules/app_python3/app_python3_mod.c b/src/modules/app_python3/app_python3_mod.c
index eb46f54f50..d250640e0c 100644
--- a/src/modules/app_python3/app_python3_mod.c
+++ b/src/modules/app_python3/app_python3_mod.c
@@ -200,19 +200,19 @@ static int child_init(int rank)
 		 * processes
 		 */
 #if PY_VERSION_HEX >= 0x03070000
-		/* this is causing abort on Python 3.8+ GH#3125
-		 * skip for now
 		PyOS_AfterFork_Parent() ;
-		*/
 #endif
 		return 0;
 	}
 	_apy_process_rank = rank;
+
+	if (rank > 0) {
 #if PY_VERSION_HEX >= 0x03070000
-	PyOS_AfterFork_Child();
+		PyOS_AfterFork_Child();
 #else
-	PyOS_AfterFork();
+		PyOS_AfterFork();
 #endif
+	}
 	if (cfg_child_init()) {
 		return -1;
 	}




More information about the sr-dev mailing list