Version 6.0.1
Features Changed
The Python exception messages raised by the WSGI adapter layer (
start_response(),write(),wsgi.input,wsgi.errors, the file wrapper, and response status/header validation) have been reworded to be more descriptive and, where appropriate, to identify mod_wsgi as their source, making them easier to diagnose.
Bugs Fixed
On 32 bit builds, validation of the Python home directory could fail with a spurious “Unable to stat Python home” warning when the directory’s inode value exceeded 32 bits, as
apr_stat()returnsAPR_INCOMPLETEin that case for ABI compatibility reasons. The stat now requests only the file type, which is all that is required.The binary
write()method onwsgi.errors.bufferandsys.stderr.bufferdid not accept amemoryview(or other bytes-like objects such asbytearray), failing with aTypeError. This dated back to the original Python 3 port, where the byte string argument parsing was carried across from Python 2 unchanged rather than being updated to the buffer protocol. It now accepts any bytes-like object. For backward compatibility astris still accepted, but doing so is now deprecated and will emit aDeprecationWarning.Compilation failed when daemon mode was not available, which is always the case on Windows, but can also occur on other platforms lacking the required
fork()and APR other-child support. Several places in code which is compiled regardless of whether daemon mode is enabled referred to daemon mode symbols, such aswsgi_daemon_processandwsgi_daemon_shutdown, without guarding the references withMOD_WSGI_WITH_DAEMONS. Those symbols are only declared when daemon mode is available, so the build failed with errors such aserror C2065: 'wsgi_daemon_shutdown': undefined variable. The references are now protected by the appropriate conditional. In addition, theapr_atomic.hheader, used by code unrelated to daemon mode, was only being included indirectly via the daemon mode header and so was missing when daemon mode was disabled; it is now included from a common header.The telemetry reporter (
WSGITelemetryServiceand the relatedWSGISlowRequestsandWSGITelemetryOptionsdirectives) delivers its datagrams over anAF_UNIXdatagram socket, which is not available on Windows, so its implementation failed to compile there. The reporter is now gated behind a newMOD_WSGI_WITH_TELEMETRYbuild conditional, defined only when not building for Windows, and the relevant call sites are guarded with it. As a result the telemetry directives are no longer registered on Windows and using one is reported as an unknown directive, matching how the daemon mode directives already behave on that platform. The platform neutral telemetry wire format definitions remain available everywhere, as the in process metrics accounting depends on them.When using daemon mode, output written to
wsgi.errors(and anything sent tosys.stdoutorsys.stderr) could be written to the main serverErrorLoginstead of theErrorLogof theVirtualHostactually handling the request. The daemon process maps each proxied request back to the correct server using listener address details supplied by the Apache child worker, but the code which populated those details was guarded byMOD_WSGI_WITH_DAEMONS, and that symbol was not defined in the relevant source file, so the guarded code was silently compiled out and no listener details were sent. This was introduced by the 6.0.0 code restructuring, which moved the definition ofMOD_WSGI_WITH_DAEMONSinto a daemon specific header that the affected source file did not include. The definition has been moved to a common header visible to all source files.When using daemon mode with a
VirtualHostselected by IP address while theListendirective used a wildcard, output written towsgi.errors(andsys.stdoutorsys.stderr) was written to the main serverErrorLoginstead of theErrorLogof thatVirtualHost. To match the request to a server the daemon process reconstructed the local socket address from the listener socket bind address, but for a wildcard listener that address is0.0.0.0(or::) and so never matched aVirtualHostgiven by a specific IP address, causing the match to fall back to the main server. The daemon now reconstructs the local address from the actual local IP the connection was received on, which is what the Apache child worker uses for the same matching.