Skip to content

Commit

Permalink
Merge branch 'release/4.4.15'
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamDumpleton committed Oct 4, 2015
2 parents 10f33c3 + 3aef8bf commit 7199a18
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 16 deletions.
1 change: 1 addition & 0 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Release Notes
.. toctree::
:maxdepth: 2

release-notes/version-4.4.15
release-notes/version-4.4.14
release-notes/version-4.4.13
release-notes/version-4.4.12
Expand Down
28 changes: 28 additions & 0 deletions docs/release-notes/version-4.4.15.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
==============
Version 4.4.15
==============

Version 4.4.15 of mod_wsgi can be obtained from:

https://codeload.github.com/GrahamDumpleton/mod_wsgi/tar.gz/4.4.15

For details on the availability of Windows binaries see:

https://github.com/GrahamDumpleton/mod_wsgi/tree/master/win32

Bugs Fixed
----------

1. When specifying multiple directories for the Python module search path
using the ``WSGIPythonPath`` directive, or the ``python-path`` option to
``WSGIDaemonProcess``, it was failing under Python 3 due to incorrect
logging. It was therefore only possible to add a single directory.

2. If Apache was already running when the mod_wsgi module was enabled or
otherwise configured to be loaded, and then an Apache graceful restart was
done so that it would be loaded for the first time, all child processes
would crash when starting up and would keep crashing, requiring Apache be
shutdown. This would occur as Python initialisation was not being performed
correctly in this specific case where mod_wsgi was loaded when Apache was
already running and a graceful restart, rather than a normal restart was
done.
28 changes: 26 additions & 2 deletions src/server/mod_wsgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -12299,16 +12299,40 @@ static int wsgi_hook_init(apr_pool_t *pconf, apr_pool_t *ptemp,
* Init function gets called twice during startup, we only
* need to actually do anything on the second time it is
* called. This avoids unecessarily initialising and then
* destroying Python for no reason.
* destroying Python for no reason. We also though have to
* deal with a special case when a graceful restart is done.
* For that we are only called once, which is generally okay
* as the 'wsgi_init' key will be set from initial start up
* of the server. The exception to this is where the module
* is only loaded into Apache when the server is already
* running. In this case we have to detect that it is not
* the initial startup, but a subsequent restart. We can do
* this by looking at whether the scoreboard has been
* initialised yet. That is probably enough, but to be safe,
* also check what generation it is.
*/

userdata_key = "wsgi_init";

apr_pool_userdata_get(&data, userdata_key, s->process->pool);

if (!data) {
apr_pool_userdata_set((const void *)1, userdata_key,
apr_pool_cleanup_null, s->process->pool);
return OK;

/*
* Check for the special case of a graceful restart and
* the module being loaded for the first time. In this
* case we still go onto perform initialisation as the
* initialisation routine for the module will not be
* called a second time.
*/

if (!ap_scoreboard_image ||
ap_get_scoreboard_global()->running_generation == 0) {

return OK;
}
}

/* Setup module version information. */
Expand Down
30 changes: 18 additions & 12 deletions src/server/wsgi_interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,16 +843,14 @@ InterpreterObject *newInterpreterObject(const char *name)

if (end) {
#if PY_MAJOR_VERSION >= 3
item = PyUnicode_Decode(start, end-start,
Py_FileSystemDefaultEncoding,
"surrogateescape");
item = PyUnicode_DecodeFSDefaultAndSize(start, end-start);
value = PyUnicode_AsUTF8(item);
#else
item = PyString_FromStringAndSize(start, end-start);
value = PyString_AsString(item);
#endif
start = end+1;

value = PyString_AsString(item);

Py_BEGIN_ALLOW_THREADS
ap_log_error(APLOG_MARK, APLOG_INFO, 0, wsgi_server,
"mod_wsgi (pid=%d): Adding '%s' to "
Expand All @@ -879,16 +877,15 @@ InterpreterObject *newInterpreterObject(const char *name)

while (result && end) {
#if PY_MAJOR_VERSION >= 3
item = PyUnicode_Decode(start, end-start,
Py_FileSystemDefaultEncoding,
"surrogateescape");
item = PyUnicode_DecodeFSDefaultAndSize(start,
end-start);
value = PyUnicode_AsUTF8(item);
#else
item = PyString_FromStringAndSize(start, end-start);
value = PyString_AsString(item);
#endif
start = end+1;

value = PyString_AsString(item);

Py_BEGIN_ALLOW_THREADS
ap_log_error(APLOG_MARK, APLOG_INFO, 0, wsgi_server,
"mod_wsgi (pid=%d): Adding '%s' to "
Expand Down Expand Up @@ -916,13 +913,21 @@ InterpreterObject *newInterpreterObject(const char *name)
}
}

#if PY_MAJOR_VERSION >= 3
item = PyUnicode_DecodeFSDefault(start);
value = PyUnicode_AsUTF8(item);
#else
item = PyString_FromString(start);
value = PyString_AsString(item);
#endif

Py_BEGIN_ALLOW_THREADS
ap_log_error(APLOG_MARK, APLOG_INFO, 0, wsgi_server,
"mod_wsgi (pid=%d): Adding '%s' to "
"path.", getpid(), start);
"path.", getpid(), value);
Py_END_ALLOW_THREADS

args = Py_BuildValue("(s)", start);
args = Py_BuildValue("(O)", item);
result = PyEval_CallObject(object, args);

if (!result) {
Expand All @@ -935,6 +940,7 @@ InterpreterObject *newInterpreterObject(const char *name)
}

Py_XDECREF(result);
Py_XDECREF(item);
Py_DECREF(args);

Py_DECREF(object);
Expand Down
4 changes: 2 additions & 2 deletions src/server/wsgi_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

#define MOD_WSGI_MAJORVERSION_NUMBER 4
#define MOD_WSGI_MINORVERSION_NUMBER 4
#define MOD_WSGI_MICROVERSION_NUMBER 14
#define MOD_WSGI_VERSION_STRING "4.4.14"
#define MOD_WSGI_MICROVERSION_NUMBER 15
#define MOD_WSGI_VERSION_STRING "4.4.15"

/* ------------------------------------------------------------------------- */

Expand Down

0 comments on commit 7199a18

Please sign in to comment.