From 315f25591dbbb9bbc3a3dcc82dce796e0183e274 Mon Sep 17 00:00:00 2001 From: Jeffrey Iadarola Date: Wed, 6 May 2026 13:54:50 -0400 Subject: [PATCH] Fixes #2738. Acquire GIL in the master process when `--py-call-uwsgi-fork-hooks` is set --- core/utils.c | 2 +- plugins/python/python_plugin.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/utils.c b/core/utils.c index c944f6478..cbf7e10d2 100644 --- a/core/utils.c +++ b/core/utils.c @@ -31,7 +31,7 @@ uint64_t uwsgi_swap64(uint64_t x) { int check_hex(char *str, int len) { int i; for (i = 0; i < len; i++) { - if ((str[i] < '0' && str[i] > '9') && (str[i] < 'a' && str[i] > 'f') && (str[i] < 'A' && str[i] > 'F') + if (!(str[i] >= '0' && str[i] <= '9') && !(str[i] >= 'a' && str[i] <= 'f') && !(str[i] >= 'A' && str[i] <= 'F') ) { return 0; } diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index c8647e08b..689461c23 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -1007,7 +1007,7 @@ int uwsgi_python_mount_app(char *mountpoint, char *app) { uwsgi.wsgi_req->appid = mountpoint; uwsgi.wsgi_req->appid_len = strlen(mountpoint); // lazy ? - if (uwsgi.mywid > 0) UWSGI_GET_GIL + if (uwsgi.mywid > 0 || up.call_uwsgi_fork_hooks) UWSGI_GET_GIL if (uwsgi.single_interpreter) { id = init_uwsgi_app(LOADER_MOUNT, app, uwsgi.wsgi_req, up.main_thread, PYTHON_APP_TYPE_WSGI); } @@ -1015,7 +1015,7 @@ int uwsgi_python_mount_app(char *mountpoint, char *app) { id = init_uwsgi_app(LOADER_MOUNT, app, uwsgi.wsgi_req, NULL, PYTHON_APP_TYPE_WSGI); } // lazy ? - if (uwsgi.mywid > 0) UWSGI_RELEASE_GIL + if (uwsgi.mywid > 0 || up.call_uwsgi_fork_hooks) UWSGI_RELEASE_GIL return id; } return -1;