diff options
author | Graham Dumpleton <Graham.Dumpleton@gmail.com> | 2015-10-04 21:56:48 +1100 |
---|---|---|
committer | Graham Dumpleton <Graham.Dumpleton@gmail.com> | 2015-10-04 21:56:48 +1100 |
commit | 7199a189616b74508e71f357088b27b49a69781d (patch) | |
tree | b49206293e3831bd0723e7cbe442c5af7f76b409 | |
parent | 10f33c324c799b7f4153db0d1de1469ffca78f5d (diff) | |
parent | 3aef8bf4fb713fc94403bfa45b13d8a7df7dfca7 (diff) | |
download | mod_wsgi-7199a189616b74508e71f357088b27b49a69781d.tar.gz |
Merge branch 'release/4.4.15'4.4.15
-rw-r--r-- | docs/release-notes.rst | 1 | ||||
-rw-r--r-- | docs/release-notes/version-4.4.15.rst | 28 | ||||
-rw-r--r-- | src/server/mod_wsgi.c | 28 | ||||
-rw-r--r-- | src/server/wsgi_interp.c | 30 | ||||
-rw-r--r-- | src/server/wsgi_version.h | 4 |
5 files changed, 75 insertions, 16 deletions
diff --git a/docs/release-notes.rst b/docs/release-notes.rst index a41e0ff..c26d875 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -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 diff --git a/docs/release-notes/version-4.4.15.rst b/docs/release-notes/version-4.4.15.rst new file mode 100644 index 0000000..a0c9302 --- /dev/null +++ b/docs/release-notes/version-4.4.15.rst @@ -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. diff --git a/src/server/mod_wsgi.c b/src/server/mod_wsgi.c index cfebe43..25ac5a1 100644 --- a/src/server/mod_wsgi.c +++ b/src/server/mod_wsgi.c @@ -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. */ diff --git a/src/server/wsgi_interp.c b/src/server/wsgi_interp.c index b3ea19a..01f6bb3 100644 --- a/src/server/wsgi_interp.c +++ b/src/server/wsgi_interp.c @@ -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 " @@ -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 " @@ -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) { @@ -935,6 +940,7 @@ InterpreterObject *newInterpreterObject(const char *name) } Py_XDECREF(result); + Py_XDECREF(item); Py_DECREF(args); Py_DECREF(object); diff --git a/src/server/wsgi_version.h b/src/server/wsgi_version.h index 59a09e8..88bb946 100644 --- a/src/server/wsgi_version.h +++ b/src/server/wsgi_version.h @@ -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" /* ------------------------------------------------------------------------- */ |