mod_wsgi
mod_wsgi copied to clipboard
Apache initialization failures due to "mod_wsgi: Unable to stat Python home"
This happened only on one server, others with the same configuration runs just fine.
We compile apache, mod_swgi and our code on CentOS 7 in 32 bit mode because of compatibility issues.
We found out that it is due to apr_stat
, used in wsgi_interp.c
file in wsgi_python_init
function when checking python home directory. The result in this specific case is APR_INCOMPLETE
. Problem in apr_stat
is with inode
which in this case is bigger than 32 bits and it is handled this way (not returned) in apr_stat
because of ABI compatibility.
The recommended solution would be one of:
-
Ask
apr_stat
only what is really needed, in this caseAPR_FINFO_TYPE
instead ofAPR_FINFO_NORM
The change would be from:rv = apr_stat(&finfo, python_home, APR_FINFO_NORM, p);
to:rv = apr_stat(&finfo, python_home, APR_FINFO_TYPE, p);
-
If
APR_FINFO_NORM
is used, acceptAPR_INCOMPLETE
whenAPR_FINFO_TYPE
flag is returned The change would be from:if (rv != APR_SUCCESS) {
toif (rv != APR_SUCCESS && !(rv == APR_INCOMPLETE && (finfo.valid & APR_FINFO_TYPE) != 0)) {