Compare commits

...

No commits in common. "c9s" and "c8" have entirely different histories.
c9s ... c8

15 changed files with 197 additions and 516 deletions

23
.gitignore vendored
View File

@ -1,22 +1 @@
mod_wsgi-3.2.tar.gz
/mod_wsgi-3.3.tar.gz
/mod_wsgi-?.?
/results_mod_wsgi/
/clog
/mod_wsgi-3.4.tar.gz
/mod_wsgi-d9d5fea585b23991f76532a9b07de7fcd3b649f4.tar.gz
/4.3.2.tar.gz
/4.4.1.tar.gz
/mod_wsgi-4.4.1.tar.gz
/mod_wsgi-4.4.3.tar.gz
/mod_wsgi-4.4.8.tar.gz
/mod_wsgi-4.5.9.tar.gz
/mod_wsgi-4.5.13.tar.gz
/mod_wsgi-4.5.15.tar.gz
/mod_wsgi-4.5.20.tar.gz
/mod_wsgi-4.6.2.tar.gz
/mod_wsgi-4.6.4.tar.gz
/mod_wsgi-4.6.5.tar.gz
/mod_wsgi-4.6.6.tar.gz
/mod_wsgi-4.6.8.tar.gz
/mod_wsgi-4.7.1.tar.gz
SOURCES/mod_wsgi-4.6.4.tar.gz

1
.mod_wsgi.metadata Normal file
View File

@ -0,0 +1 @@
6a0cc67546a5e172a885324f3e58b8be5f4e0e58 SOURCES/mod_wsgi-4.6.4.tar.gz

View File

@ -1,41 +0,0 @@
From 0f34844009075391c55419a3afb90e469facf35e Mon Sep 17 00:00:00 2001
From: Graham Dumpleton <Graham.Dumpleton@gmail.com>
Date: Tue, 14 May 2019 16:14:07 +1000
Subject: [PATCH] Changed functions to pre/post actions when forking.
---
src/server/mod_wsgi.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/server/mod_wsgi.c b/src/server/mod_wsgi.c
index 2e4bb24..bf55945 100644
--- a/src/server/mod_wsgi.c
+++ b/src/server/mod_wsgi.c
@@ -4345,8 +4345,13 @@ static void wsgi_python_child_init(apr_pool_t *p)
* do it if Python was initialised in parent process.
*/
- if (wsgi_python_initialized && !wsgi_python_after_fork)
+ if (wsgi_python_initialized && !wsgi_python_after_fork) {
+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7)
+ PyOS_AfterFork_Child();
+#else
PyOS_AfterFork();
+#endif
+ }
/* Finalise any Python objects required by child process. */
@@ -10422,6 +10427,12 @@ static int wsgi_start_process(apr_pool_t *p, WSGIDaemonProcess *daemon)
wsgi_exit_daemon_process(0);
}
+ if (wsgi_python_initialized) {
+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7)
+ PyOS_AfterFork_Parent();
+#endif
+ }
+
apr_pool_note_subprocess(p, &daemon->process, APR_KILL_AFTER_TIMEOUT);
apr_proc_other_child_register(&daemon->process, wsgi_manage_process,
daemon, NULL, p);

View File

@ -0,0 +1,131 @@
https://github.com/GrahamDumpleton/mod_wsgi/pull/364
https://bugzilla.redhat.com/show_bug.cgi?id=1602620
--- mod_wsgi-4.6.4/src/server/__init__.py.warnings
+++ mod_wsgi-4.6.4/src/server/__init__.py
@@ -103,7 +103,6 @@
for name in mimetypes.knownfiles:
if os.path.exists(name):
return name
- break
else:
return name
--- mod_wsgi-4.6.4/src/server/mod_wsgi.c.warnings
+++ mod_wsgi-4.6.4/src/server/mod_wsgi.c
@@ -2108,9 +2108,11 @@
/* Publish event for the start of the response. */
if (wsgi_event_subscribers()) {
+#if 0
WSGIThreadInfo *thread_info;
thread_info = wsgi_thread_info(0, 0);
+#endif
event = PyDict_New();
@@ -6349,10 +6351,7 @@
/* Need to cast const away. */
- if (r)
- id = &((request_rec *)r)->log_id;
- else
- id = &((conn_rec *)c)->log_id;
+ id = &((request_rec *)r)->log_id;
ap_run_generate_log_id(c, r, id);
}
@@ -8510,6 +8509,7 @@
ap_log_error(APLOG_MARK, APLOG_ALERT, errno, wsgi_server,
"mod_wsgi (pid=%d): Couldn't bind unix domain "
"socket '%s'.", getpid(), process->socket_path);
+ close(sockfd);
return -1;
}
@@ -8521,6 +8521,7 @@
ap_log_error(APLOG_MARK, APLOG_ALERT, errno, wsgi_server,
"mod_wsgi (pid=%d): Couldn't listen on unix domain "
"socket.", getpid());
+ close(sockfd);
return -1;
}
@@ -8555,6 +8556,7 @@
"mod_wsgi (pid=%d): Couldn't change owner of unix "
"domain socket '%s' to uid=%ld.", getpid(),
process->socket_path, (long)socket_uid);
+ close(sockfd);
return -1;
}
}
@@ -13338,8 +13340,10 @@
for (i = 0; i < wsgi_daemon_list->nelts; ++i) {
entry = &entries[i];
- close(entry->listener_fd);
- entry->listener_fd = -1;
+ if (entry->listener_fd != -1) {
+ close(entry->listener_fd);
+ entry->listener_fd = -1;
+ }
}
}
#endif
@@ -13751,8 +13755,8 @@
if (trusted_proxy) {
for (i=0; i<trusted_proxy_headers->nelts; i++) {
- const char *name = NULL;
- const char *value = NULL;
+ const char *name;
+ const char *value;
name = ((const char**)trusted_proxy_headers->elts)[i];
value = apr_table_get(r->subprocess_env, name);
@@ -13879,11 +13883,9 @@
*/
for (i=0; i<trusted_proxy_headers->nelts; i++) {
- const char *name = NULL;
- const char *value = NULL;
+ const char *name;
name = ((const char**)trusted_proxy_headers->elts)[i];
- value = apr_table_get(r->subprocess_env, name);
if (!strcmp(name, "HTTP_X_FORWARDED_FOR") ||
!strcmp(name, "HTTP_X_REAL_IP")) {
--- mod_wsgi-4.6.4/src/server/wsgi_logger.c.warnings
+++ mod_wsgi-4.6.4/src/server/wsgi_logger.c
@@ -694,9 +694,11 @@
PyObject *object = NULL;
if (wsgi_event_subscribers()) {
+#if 0
WSGIThreadInfo *thread_info;
thread_info = wsgi_thread_info(0, 0);
+#endif
event = PyDict_New();
--- mod_wsgi-4.6.4/src/server/wsgi_python.h.warnings
+++ mod_wsgi-4.6.4/src/server/wsgi_python.h
@@ -21,6 +21,12 @@
/* ------------------------------------------------------------------------- */
+#ifdef _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#endif
+#ifdef _XOPEN_SOURCE
+#undef _XOPEN_SOURCE
+#endif
#include <Python.h>
#if !defined(PY_VERSION_HEX)

View File

@ -1,44 +1,43 @@
%{!?_httpd_apxs: %{expand: %%global _httpd_apxs %%{_sbindir}/apxs}}
%{!?_httpd_mmn: %{expand: %%global _httpd_mmn %%(cat %{_includedir}/httpd/.mmn 2>/dev/null || echo 0-0)}}
%{!?_httpd_confdir: %{expand: %%global _httpd_confdir %%{_sysconfdir}/httpd/conf.d}}
# /etc/httpd/conf.d with httpd < 2.4 and defined as /etc/httpd/conf.modules.d with httpd >= 2.4
%{!?_httpd_modconfdir: %{expand: %%global _httpd_modconfdir %%{_sysconfdir}/httpd/conf.d}}
%{!?_httpd_moddir: %{expand: %%global _httpd_moddir %%{_libdir}/httpd/modules}}
%if 0%{?fedora} || 0%{?rhel} > 7
%global with_python3 1
%bcond_without python3
%else
%global with_python3 0
%bcond_with python3
%endif
%if (0%{?fedora} > 0 && 0%{?fedora} < 32) || (0%{?rhel} > 0 && 0%{?rhel} <= 7)
%global with_python2 1
%if 0%{?fedora} || 0%{?rhel} <= 7
%bcond_without python2
%else
%global with_python2 0
%bcond_with python2
%endif
%if %{with python3} && !%{with python2}
%global py3dir .
%endif
Name: mod_wsgi
Version: 4.7.1
Release: 12%{?dist}
Version: 4.6.4
Release: 5%{?dist}
Summary: A WSGI interface for Python web applications in Apache
Group: System Environment/Libraries
License: ASL 2.0
URL: https://modwsgi.readthedocs.io/
Source0: https://github.com/GrahamDumpleton/mod_wsgi/archive/%{version}.tar.gz#/mod_wsgi-%{version}.tar.gz
Source1: wsgi.conf
Source2: wsgi-python3.conf
Patch1: mod_wsgi-4.5.20-exports.patch
Patch2: mod_wsgi-4.7.1-remove-rpath.patch
Patch3: mod_wsgi-4.7.1-warning-segfaults.patch
Patch4: mod_wsgi-4.9.1-request-limit.patch
Patch5: mod_wsgi-4.7.1-dont-destroy-py-intr.patch
BuildRequires: make
Patch2: mod_wsgi-4.6.4-warnings.patch
Patch3: mod_wsgi-4.9.1-request-limit.patch
BuildRequires: httpd-devel
BuildRequires: python3-sphinx
BuildRequires: gcc
# Suppress auto-provides for module DSO
%global __provides_exclude_from %{_httpd_moddir}/.*\\.so$
%{?filter_provides_in: %filter_provides_in %{_httpd_moddir}/.*\.so$}
%{?filter_setup}
%global _description\
The mod_wsgi adapter is an Apache module that provides a WSGI compliant\
@ -50,11 +49,11 @@ existing WSGI adapters for mod_python or CGI.\
%description %_description
%if 0%{?with_python2} > 0
%if %{with python2}
%package -n python2-%{name}
Summary: %summary
Requires: httpd-mmn = %{_httpd_mmn}
BuildRequires: python2-devel, python2-setuptools
BuildRequires: python2-devel
%{?python_provide:%python_provide python2-%{name}}
# Remove before F30
Provides: mod_wsgi = %{version}-%{release}
@ -65,56 +64,51 @@ Obsoletes: mod_wsgi < %{version}-%{release}
%endif
%if 0%{?with_python3} > 0
%if %{with python3}
%package -n python3-%{name}
Summary: %summary
Requires: httpd-mmn = %{_httpd_mmn}
BuildRequires: python3-devel, python3-sphinx, python3-sphinx_rtd_theme
%if 0%{?with_python2} == 0
Provides: mod_wsgi = %{version}-%{release}
Provides: mod_wsgi%{?_isa} = %{version}-%{release}
Obsoletes: mod_wsgi < %{version}-%{release}
%endif
BuildRequires: python3-devel
%description -n python3-%{name} %_description
%endif
%prep
%autosetup -p1 -n %{name}-%{version}
%setup -qn %{name}-%{version}
%patch1 -p1 -b .exports
%patch2 -p1 -b .warnings
%patch3 -p1 -b .request-limit
: Python2=%{with_python2} Python3=%{with_python3}
%if "%{py3dir}" != "."
cp -a . %{py3dir}
%endif
%build
%if %{with_python3}
make -C docs html SPHINXBUILD=%{_bindir}/sphinx-build-3
%endif
make -C docs html
export LDFLAGS="$RPM_LD_FLAGS -L%{_libdir}"
export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"
%if 0%{?with_python3} > 0
mkdir py3build/
# this always produces an error (because of trying to copy py3build
# into itself) but we don't mind, so || :
cp -R * py3build/ || :
pushd py3build
%if %{with python2}
%configure --enable-shared --with-apxs=%{_httpd_apxs} --with-python=python2
make %{?_smp_mflags}
%py2_build
%endif
%if %{with python3}
pushd %{py3dir}
%configure --enable-shared --with-apxs=%{_httpd_apxs} --with-python=python3
%{make_build}
make %{?_smp_mflags}
%py3_build
popd
%endif
%if 0%{?with_python2} > 0
%configure --enable-shared --with-apxs=%{_httpd_apxs} --with-python=python2
%{make_build}
%py2_build
%endif
%install
# first install python3 variant and rename the so file
%if 0%{?with_python3} > 0
pushd py3build
%if %{with python3}
pushd %{py3dir}
make install DESTDIR=$RPM_BUILD_ROOT LIBEXECDIR=%{_httpd_moddir}
mv $RPM_BUILD_ROOT%{_httpd_moddir}/mod_wsgi{,_python3}.so
@ -129,7 +123,7 @@ popd
%endif
# second install python2 variant
%if 0%{?with_python2} > 0
%if %{with python2}
make install DESTDIR=$RPM_BUILD_ROOT LIBEXECDIR=%{_httpd_moddir}
install -d -m 755 $RPM_BUILD_ROOT%{_httpd_modconfdir}
@ -141,7 +135,7 @@ mv $RPM_BUILD_ROOT%{_bindir}/mod_wsgi-express{,-2}
ln -s %{_bindir}/mod_wsgi-express-2 $RPM_BUILD_ROOT%{_bindir}/mod_wsgi-express
%endif
%if 0%{?with_python2} > 0
%if %{with python2}
%files -n python2-%{name}
%license LICENSE
%doc CREDITS.rst README.rst
@ -153,7 +147,7 @@ ln -s %{_bindir}/mod_wsgi-express-2 $RPM_BUILD_ROOT%{_bindir}/mod_wsgi-express
%{_bindir}/mod_wsgi-express
%endif
%if 0%{?with_python3} > 0
%if %{with python3}
%files -n python3-%{name}
%license LICENSE
%doc CREDITS.rst README.rst
@ -165,102 +159,31 @@ ln -s %{_bindir}/mod_wsgi-express-2 $RPM_BUILD_ROOT%{_bindir}/mod_wsgi-express
%endif
%changelog
* Thu Jun 05 2025 Luboš Uhliarik <luhliari@redhat.com> - 4.7.1-12
- Resolves: RHEL-65419 - httpd with python3-mod_wsgi is stalling in process
destruction
* Tue Sep 06 2022 Luboš Uhliarik <luhliari@redhat.com> - 4.6.4-5
- Resolves: #2122695 - Core dumped upon file upload >= 1GB
* Thu Sep 01 2022 Luboš Uhliarik <luhliari@redhat.com> - 4.7.1-11
- Resolves: #2122694 - Core dumped upon file upload >= 1GB
* Wed Dec 04 2019 Lubos Uhliarik <luhliari@redhat.com> - 4.6.4-4
- Resolves: #1779705 - python3-mod_wsgi: Remove the Provides and Obsoletes for
the name `mod_wsgi`
* Thu Apr 07 2022 Luboš Uhliarik <luhliari@redhat.com> - 4.7.1-10
- Resolves: #2072969 - Missing debuginfo
* Thu Dec 13 2018 Joe Orton <jorton@redhat.com> - 4.6.4-3
- avoid unstripped binaries, re-enable debugsource generation (#1659086)
* Tue Feb 08 2022 Tomas Orsava <torsava@redhat.com> - 4.7.1-9
- Add automatically generated Obsoletes tag with the python39- prefix
for smoother upgrade from RHEL8
- Use the modern way of filtering Provides not to interfere with modern Python
RPM generators
- Related: rhbz#1990421
* Tue Dec 11 2018 Joe Orton <jorton@redhat.com> - 4.6.4-2
- fix covscan warnings (#1602620)
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 4.7.1-8
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Wed Jun 27 2018 Joe Orton <jorton@redhat.com> - 4.6.4-1
- update to 4.6.4 (#1592687)
* Thu Jul 01 2021 Luboš Uhliarik <luhliari@redhat.com> - 4.7.1-7
- Resolves: #1976169 - mod_wsgi segfaults when python program outputs a warning
message
* Tue Jun 26 2018 Tomas Orsava <torsava@redhat.com> - 4.6.2-5
- Switch to using Python 3 version of sphinx
* Tue Jun 08 2021 Luboš Uhliarik <luhliari@redhat.com> - 4.7.1-6
- Resolves: #1969555 - remove rpath
* Tue Jun 26 2018 Tomas Orsava <torsava@redhat.com> - 4.6.2-4
- Update conditionals into bcond's so they can be manipulated during modular
builds
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 4.7.1-5
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.7.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.7.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 4.7.1-2
- Rebuilt for Python 3.9
* Wed May 13 2020 Joe Orton <jorton@redhat.com> - 4.7.1-1
- update to 4.7.1 (#1721376)
* Thu Feb 13 2020 Tom Stellard <tstellar@redhat.com> - 4.6.8-3
- Use make_build macro instead of just make
- https://docs.fedoraproject.org/en-US/packaging-guidelines/#_parallel_make
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.6.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Mon Nov 11 2019 Joe Orton <jorton@redhat.com> - 4.6.8-1
- update to 4.6.8 (#1721376)
* Mon Nov 11 2019 Joe Orton <jorton@redhat.com> - 4.6.6-6
- try again to drop Python 2
* Tue Oct 29 2019 Joe Orton <jorton@redhat.com> - 4.6.6-5
- drop python2 build
* Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 4.6.6-4
- Rebuilt for Python 3.8.0rc1 (#1748018)
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 4.6.6-3
- Rebuilt for Python 3.8
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.6.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Fri Jun 07 2019 Matthias Runge <mrunge@redhat.com> - 4.6.6-1
- update to 4.6.6 (rhbz#1718151)
* Wed May 29 2019 Miro Hrončok <mhroncok@redhat.com> - 4.6.5-1
- update to 4.6.5
* Tue Apr 16 2019 Joe Orton <jorton@redhat.com> - 4.6.4-4
- only build docs with Python 3
- fix build on Fedora>30 and RHEL 7
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.6.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Tue Jul 31 2018 Adam Williamson <awilliam@redhat.com> - 4.6.4-2
- Run Python 3 build in a subdir, so module isn't linked against both
libpython 2 and libpython 3 (rhbz#1609491)
* Fri Jul 20 2018 Matthias Runge <mrunge@redhat.com> - 4.6.4-1
- update to 4.6.4 (rhbz#1560329)
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.6.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 4.6.2-4
- Rebuilt for Python 3.7
* Fri Apr 20 2018 Joe Orton <jorton@redhat.com> - 4.6.2-3
- use sphinx-build-3 if python2 support is disabled
* Tue Jun 26 2018 Tomas Orsava <torsava@redhat.com> - 4.6.2-3
- Fix the invocation of Python 2 to a versioned executable
* Thu Mar 22 2018 Troy Dawson <tdawson@redhat.com> - 4.6.2-2
- Update conditionals.

View File

@ -1,55 +0,0 @@
From b03b02df6318afe26052db5b0365732152cacea2 Mon Sep 17 00:00:00 2001
From: Graham Dumpleton <Graham.Dumpleton@gmail.com>
Date: Tue, 14 May 2019 16:14:42 +1000
Subject: [PATCH] Use official APIs for accessing interpreter list.
---
src/server/wsgi_interp.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/server/wsgi_interp.c b/src/server/wsgi_interp.c
index 4a94850..3fbca04 100644
--- a/src/server/wsgi_interp.c
+++ b/src/server/wsgi_interp.c
@@ -338,9 +338,10 @@ static PyObject *ShutdownInterpreter_call(
PyThreadState_Swap(NULL);
- tstate = tstate->interp->tstate_head;
+ tstate = PyInterpreterState_ThreadHead(tstate->interp);
+
while (tstate) {
- tstate_next = tstate->next;
+ tstate_next = PyThreadState_Next(tstate);
if (tstate != tstate_save) {
PyThreadState_Swap(tstate);
PyThreadState_Clear(tstate);
@@ -436,9 +437,13 @@ InterpreterObject *newInterpreterObject(const char *name)
*/
if (!name) {
+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7)
+ interp = PyInterpreterState_Main();
+#else
interp = PyInterpreterState_Head();
- while (interp->next)
- interp = interp->next;
+ while (PyInterpreterState_Next(interp))
+ interp = PyInterpreterState_Next(interp);
+#endif
name = "";
}
@@ -1883,9 +1888,10 @@ static void Interpreter_dealloc(InterpreterObject *self)
PyThreadState_Swap(NULL);
- tstate = tstate->interp->tstate_head;
+ tstate = PyInterpreterState_ThreadHead(tstate->interp);
+
while (tstate) {
- tstate_next = tstate->next;
+ tstate_next = PyThreadState_Next(tstate);
if (tstate != tstate_save) {
PyThreadState_Swap(tstate);
PyThreadState_Clear(tstate);

View File

@ -1,9 +0,0 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional}
- !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier2.functional}
- !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier3.functional}
- !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.acceptance-tier.functional}

View File

@ -1,181 +0,0 @@
diff --git a/src/server/__init__.py b/src/server/__init__.py
index 6b4a82e..6b74ada 100644
--- a/src/server/__init__.py
+++ b/src/server/__init__.py
@@ -335,6 +335,13 @@ WSGISocketPrefix %(server_root)s/wsgi
WSGISocketRotation Off
+<IfDefine ORPHAN_INTERPRETER>
+WSGIDestroyInterpreter Off
+</IfDefine>
+<IfDefine !ORPHAN_INTERPRETER>
+WSGIDestroyInterpreter On
+</IfDefine>
+
<IfDefine !ONE_PROCESS>
WSGIRestrictEmbedded On
<IfDefine MOD_WSGI_MULTIPROCESS>
@@ -2565,6 +2572,10 @@ option_list = (
help='Specify the name of a separate log file to be used for '
'the managed service.'),
+ optparse.make_option('--orphan-interpreter', action='store_true',
+ default=False, help='Flag indicating whether should skip over '
+ 'destroying the Python interpreter on process shutdown.'),
+
optparse.make_option('--enable-docs', action='store_true', default=False,
help='Flag indicating whether the mod_wsgi documentation should '
'be made available at the /__wsgi__/docs sub URL.'),
@@ -3161,6 +3172,9 @@ def _cmd_setup_server(command, args, options):
else:
options['https_url'] = None
+ if options['orphan_interpreter']:
+ options['httpd_arguments_list'].append('-DORPHAN_INTERPRETER')
+
if any((options['enable_debugger'], options['enable_coverage'],
options['enable_profiler'], options['enable_recorder'],
options['enable_gdb'])):
diff --git a/src/server/mod_wsgi.c b/src/server/mod_wsgi.c
index 5a61999..adb5875 100644
--- a/src/server/mod_wsgi.c
+++ b/src/server/mod_wsgi.c
@@ -4289,6 +4289,11 @@ static apr_status_t wsgi_python_child_cleanup(void *data)
wsgi_publish_process_stopping(wsgi_shutdown_reason);
#endif
+ /* Skip destruction of Python interpreter. */
+
+ if (wsgi_server_config->destroy_interpreter == 0)
+ return APR_SUCCESS;
+
/* In a multithreaded MPM must protect table. */
#if APR_HAS_THREADS
@@ -5023,6 +5028,28 @@ static const char *wsgi_set_python_hash_seed(cmd_parms *cmd, void *mconfig,
return NULL;
}
+static const char *wsgi_set_destroy_interpreter(cmd_parms *cmd, void *mconfig,
+ const char *f)
+{
+ const char *error = NULL;
+ WSGIServerConfig *sconfig = NULL;
+
+ error = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+ if (error != NULL)
+ return error;
+
+ sconfig = ap_get_module_config(cmd->server->module_config, &wsgi_module);
+
+ if (strcasecmp(f, "Off") == 0)
+ sconfig->destroy_interpreter = 0;
+ else if (strcasecmp(f, "On") == 0)
+ sconfig->destroy_interpreter = 1;
+ else
+ return "WSGIDestroyInterpreter must be one of: Off | On";
+
+ return NULL;
+}
+
static const char *wsgi_set_restrict_embedded(cmd_parms *cmd, void *mconfig,
const char *f)
{
@@ -16188,6 +16215,9 @@ static const command_rec wsgi_commands[] =
AP_INIT_TAKE1("WSGIPythonHashSeed", wsgi_set_python_hash_seed,
NULL, RSRC_CONF, "Python hash seed."),
+ AP_INIT_TAKE1("WSGIDestroyInterpreter", wsgi_set_destroy_interpreter,
+ NULL, RSRC_CONF, "Enable/Disable destruction of Python interpreter."),
+
#if defined(MOD_WSGI_WITH_DAEMONS)
AP_INIT_TAKE1("WSGIRestrictEmbedded", wsgi_set_restrict_embedded,
NULL, RSRC_CONF, "Enable/Disable use of embedded mode."),
diff --git a/src/server/wsgi_interp.c b/src/server/wsgi_interp.c
index 48680f4..a010c42 100644
--- a/src/server/wsgi_interp.c
+++ b/src/server/wsgi_interp.c
@@ -2019,6 +2019,11 @@ apr_status_t wsgi_python_term(void)
{
PyObject *module = NULL;
+ /* Skip destruction of Python interpreter. */
+
+ if (wsgi_server_config->destroy_interpreter == 0)
+ return APR_SUCCESS;
+
ap_log_error(APLOG_MARK, APLOG_INFO, 0, wsgi_server,
"mod_wsgi (pid=%d): Terminating Python.", getpid());
diff --git a/src/server/wsgi_server.c b/src/server/wsgi_server.c
index b3eca28..c038827 100644
--- a/src/server/wsgi_server.c
+++ b/src/server/wsgi_server.c
@@ -101,6 +101,7 @@ WSGIServerConfig *newWSGIServerConfig(apr_pool_t *p)
object->python_hash_seed = NULL;
+ object->destroy_interpreter = -1;
object->restrict_embedded = -1;
object->restrict_stdin = -1;
object->restrict_stdout = -1;
diff --git a/src/server/wsgi_server.h b/src/server/wsgi_server.h
index 07ded14..f1455b6 100644
--- a/src/server/wsgi_server.h
+++ b/src/server/wsgi_server.h
@@ -87,6 +87,7 @@ typedef struct {
const char *python_hash_seed;
+ int destroy_interpreter;
int restrict_embedded;
int restrict_stdin;
int restrict_stdout;
diff --git a/tests/events.wsgi b/tests/events.wsgi
index 50b9246..228ef11 100644
--- a/tests/events.wsgi
+++ b/tests/events.wsgi
@@ -5,6 +5,7 @@ import traceback
import time
import os
import threading
+import atexit
try:
mod_wsgi.request_data()
@@ -18,7 +19,7 @@ def wrapper(application):
return _application
def event_handler(name, **kwargs):
- print('EVENT', name, kwargs, os.getpid(), mod_wsgi.application_group)
+ print('EVENT-HANDLER', name, kwargs, os.getpid(), mod_wsgi.application_group)
if name == 'request_started':
thread = threading.current_thread()
request_data = kwargs['request_data']
@@ -35,12 +36,24 @@ def event_handler(name, **kwargs):
elif name == 'process_stopping':
print('SHUTDOWN', mod_wsgi.active_requests)
-print('EVENTS', mod_wsgi.event_callbacks)
+print('EVENTS#ALL', mod_wsgi.event_callbacks)
mod_wsgi.subscribe_events(event_handler)
+def shutdown_handler(event, **kwargs):
+ print('SHUTDOWN-HANDLER', event, kwargs)
+
+print('EVENTS#SHUTDOWN', mod_wsgi.event_callbacks)
+
+mod_wsgi.subscribe_shutdown(shutdown_handler)
+
print('CALLBACKS', mod_wsgi.event_callbacks)
+def atexit_handler():
+ print('ATEXIT-HANDLER')
+
+atexit.register(atexit_handler)
+
def application(environ, start_response):
failure_mode = environ.get('HTTP_X_FAILURE_MODE', '')
failure_mode = failure_mode.split()

View File

@ -1,20 +0,0 @@
diff --git a/setup.py b/setup.py
index bf272ba..824957d 100644
--- a/setup.py
+++ b/setup.py
@@ -465,15 +465,6 @@ EXTRA_COMPILE_FLAGS = (EXTRA_INCLUDES + CPPFLAGS + EXTRA_CPPFLAGS +
CFLAGS + EXTRA_CFLAGS + APR_INCLUDES + APU_INCLUDES)
EXTRA_LINK_ARGS = PYTHON_LDFLAGS + PYTHON_LDLIBS
-# Force adding of LD_RUN_PATH for platforms that may need it.
-
-if os.name != 'nt':
- LD_RUN_PATH = os.environ.get('LD_RUN_PATH', '')
- LD_RUN_PATH += ':%s:%s' % (PYTHON_LIBDIR, PYTHON_CFGDIR)
- LD_RUN_PATH = LD_RUN_PATH.lstrip(':')
-
- os.environ['LD_RUN_PATH'] = LD_RUN_PATH
-
# On MacOS X, recent versions of Apple's Apache do not support compiling
# Apache modules with a target older than 10.8. This is because it
# screws up Apache APR % formats for apr_time_t, which breaks daemon

View File

@ -1,46 +0,0 @@
From 2c9d1b3e725ad2a072e9fef4cb1cb0bb9ae2d540 Mon Sep 17 00:00:00 2001
From: Graham Dumpleton <Graham.Dumpleton@gmail.com>
Date: Sat, 13 Feb 2021 11:05:39 +1100
Subject: [PATCH] Fix deprecation warning in PyArg_ParseTuple().
---
docs/release-notes/version-4.8.0.rst | 5 +++++
src/server/wsgi_logger.c | 4 ++--
src/server/wsgi_python.h | 2 ++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/server/wsgi_logger.c b/src/server/wsgi_logger.c
index 71c7d69e..df35887e 100644
--- a/src/server/wsgi_logger.c
+++ b/src/server/wsgi_logger.c
@@ -223,7 +223,7 @@ static PyObject *Log_isatty(LogObject *self, PyObject *args)
return Py_False;
}
-static void Log_queue(LogObject *self, const char *msg, int len)
+static void Log_queue(LogObject *self, const char *msg, Py_ssize_t len)
{
const char *p = NULL;
const char *q = NULL;
@@ -330,7 +330,7 @@ static void Log_queue(LogObject *self, const char *msg, int len)
static PyObject *Log_write(LogObject *self, PyObject *args)
{
const char *msg = NULL;
- int len = -1;
+ Py_ssize_t len = -1;
WSGIThreadInfo *thread_info = NULL;
diff --git a/src/server/wsgi_python.h b/src/server/wsgi_python.h
index 0464fe6d..5c10cae5 100644
--- a/src/server/wsgi_python.h
+++ b/src/server/wsgi_python.h
@@ -21,6 +21,8 @@
/* ------------------------------------------------------------------------- */
+#define PY_SSIZE_T_CLEAN 1
+
#include <Python.h>
#if !defined(PY_VERSION_HEX)

View File

@ -1 +0,0 @@
SHA512 (mod_wsgi-4.7.1.tar.gz) = cbb5ec53d55e47a83f2b0630527c6a52b48ef21d5d2c18adcb875fc455795b39b3c93f4a86dfbf9738c0bd554d86cc4912cc9ff83c428af302ab94a61f66b5b4