Skip to content

Commit 64df7cf

Browse files
Merge branch 'release/4.5.10'
2 parents d4af4d9 + 346bba7 commit 64df7cf

File tree

8 files changed

+93
-37
lines changed

8 files changed

+93
-37
lines changed

README.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
========
2-
MOD_WSGI
3-
========
4-
51
Overview
62
--------
73

docs/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Contributing
33
============
44

5-
The mod_wsgi package is a solo effort by Graham Dumpletaon.
5+
The mod_wsgi package is a solo effort by Graham Dumpleton.
66

77
The package is developed purely in the author's spare time and is not
88
funded in any way by a company, nor is it developed for a specific

docs/release-notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Release Notes
55
.. toctree::
66
:maxdepth: 2
77

8+
release-notes/version-4.5.10
89
release-notes/version-4.5.9
910
release-notes/version-4.5.8
1011
release-notes/version-4.5.7
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
==============
2+
Version 4.5.10
3+
==============
4+
5+
Version 4.5.10 of mod_wsgi can be obtained from:
6+
7+
https://codeload.github.com/GrahamDumpleton/mod_wsgi/tar.gz/4.5.10
8+
9+
Bugs Fixed
10+
----------
11+
12+
* In version 4.5.9, the version number 4.5.8 was being incorrectly reported
13+
via ``mod_wsgi.version`` in the per request WSGI environ dictionary.
14+
15+
* When using Anaconda Python on MacOS X, the Python shared library wasn't
16+
being resolved correctly due to changes in Anaconda Python, meaning it
17+
cannot be used in embedded systems which load Python via a dynamically
18+
loaded module, such as in Apache. When using ``mod_wsgi-express`` the
19+
Python shared library is now forcibly loaded before the mod_wsgi module
20+
is loaded in Apache. If doing manual Apache configration, you will need
21+
to add before the ``LoadModule`` line for ``wsgi_module``, a ``LoadFile``
22+
directive which loads the Ananconda Python shared library by its full
23+
path from where it is located in the Anaconda Python ``lib`` directory.
24+
25+
* Startup timeout wasn't being cancelled after succesful load of the WSGI
26+
script file and instead was only being done after first request had
27+
finished. This meant that if first request took longer than the startup
28+
timeout the process would be wrongly restarted.
29+
30+
* Fix parsing of ``Content-Length`` header returned in daemon mode so that
31+
responses greater than 2GB in size could be returned.
32+
33+
* Using incorrect header files in workaround to be able to compile mod_wsgi
34+
on MacOSX Sierra when using ``pip install``. Was using old MacOS X 10.6
35+
SDK which are header files for Apache 2.2. Was running, but should not
36+
have worked at all. Possibility this still may not work or might break.
37+
No choice until Apple fixes their broken Xcode and Apache installation.

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,9 @@ def get_apu_includes():
276276
# case we manually set the locations of the Apache and APR header files.
277277

278278
if (not os.path.exists(APR_CONFIG) and
279-
os.path.exists('/Developer/SDKs/MacOSX10.6.sdk')):
280-
INCLUDEDIR = '/Developer/SDKs/MacOSX10.6.sdk/usr/include/apache2'
281-
APR_INCLUDES = ['-I/Developer/SDKs/MacOSX10.6.sdk/usr/include/apr-1']
279+
os.path.exists('/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdks/MacOSX.sdk')):
280+
INCLUDEDIR = '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdks/MacOSX.sdk/usr/include/apache2'
281+
APR_INCLUDES = ['-I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdks/MacOSX.sdk/usr/include/apr-1']
282282
APU_INCLUDES = []
283283
else:
284284
APR_INCLUDES = get_apr_includes().split()

src/server/__init__.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
_py_version = '%s%s' % sys.version_info[:2]
2727
_py_soabi = ''
2828
_py_soext = '.so'
29+
_py_dylib = ''
2930

3031
try:
3132
import imp
@@ -35,6 +36,14 @@
3536
_py_soabi = sysconfig.get_config_var('SOABI')
3637
_py_soext = sysconfig.get_config_var('SO')
3738

39+
if (sysconfig.get_config_var('WITH_DYLD') and
40+
sysconfig.get_config_var('LIBDIR') and
41+
sysconfig.get_config_var('LDLIBRARY')):
42+
_py_dylib = os.path.join(sysconfig.get_config_var('LIBDIR'),
43+
sysconfig.get_config_var('LDLIBRARY'))
44+
if not os.path.exists(_py_dylib):
45+
_py_dylib = ''
46+
3847
except ImportError:
3948
pass
4049

@@ -252,6 +261,10 @@ def find_mimetypes():
252261
</IfDefine>
253262
</IfModule>
254263
264+
<IfDefine MOD_WSGI_LOAD_PYTHON_DYLIB>
265+
LoadFile '%(python_dylib)s'
266+
</IfDefine>
267+
255268
LoadModule wsgi_module '%(mod_wsgi_so)s'
256269
257270
<IfDefine MOD_WSGI_SERVER_METRICS>
@@ -3170,14 +3183,19 @@ def _cmd_setup_server(command, args, options):
31703183
_mpm_module_defines(options['modules_directory'],
31713184
options['server_mpm_variables']))
31723185

3173-
options['httpd_arguments'] = '-f %s %s' % (options['httpd_conf'],
3174-
' '.join(options['httpd_arguments_list']))
3175-
31763186
options['python_executable'] = sys.executable
31773187

31783188
options['shlibpath_var'] = apxs_config.SHLIBPATH_VAR
31793189
options['shlibpath'] = apxs_config.SHLIBPATH
31803190

3191+
if _py_dylib:
3192+
options['httpd_arguments_list'].append('-DMOD_WSGI_LOAD_PYTHON_DYLIB')
3193+
3194+
options['python_dylib'] = _py_dylib
3195+
3196+
options['httpd_arguments'] = '-f %s %s' % (options['httpd_conf'],
3197+
' '.join(options['httpd_arguments_list']))
3198+
31813199
generate_wsgi_handler_script(options)
31823200

31833201
if options['with_newrelic_platform']:
@@ -3320,6 +3338,8 @@ def cmd_module_config(params):
33203338
prefix = sys.prefix
33213339
prefix = os.path.normpath(prefix)
33223340

3341+
if _py_dylib:
3342+
print('LoadFile "%s"' % _py_dylib)
33233343
print('LoadModule wsgi_module "%s"' % module_path)
33243344
print('WSGIPythonHome "%s"' % prefix)
33253345

@@ -3343,6 +3363,8 @@ def cmd_install_module(params):
33433363

33443364
shutil.copyfile(where(), target)
33453365

3366+
if _py_dylib:
3367+
print('LoadFile "%s"' % _py_dylib)
33463368
print('LoadModule wsgi_module "%s"' % target)
33473369
print('WSGIPythonHome "%s"' % os.path.normpath(sys.prefix))
33483370

src/server/mod_wsgi.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -969,9 +969,9 @@ typedef struct {
969969
int init;
970970
int done;
971971
char *buffer;
972-
apr_size_t size;
973-
apr_size_t offset;
974-
apr_size_t length;
972+
apr_off_t size;
973+
apr_off_t offset;
974+
apr_off_t length;
975975
apr_bucket_brigade *bb;
976976
int seen_eos;
977977
int seen_error;
@@ -1233,11 +1233,11 @@ static apr_int64_t Input_read_from_input(InputObject *self, char *buffer,
12331233

12341234
static PyObject *Input_read(InputObject *self, PyObject *args)
12351235
{
1236-
long size = -1;
1236+
apr_off_t size = -1;
12371237

12381238
PyObject *result = NULL;
12391239
char *buffer = NULL;
1240-
apr_size_t length = 0;
1240+
apr_off_t length = 0;
12411241
int init = 0;
12421242

12431243
apr_int64_t n;
@@ -1510,11 +1510,11 @@ static PyObject *Input_read(InputObject *self, PyObject *args)
15101510

15111511
static PyObject *Input_readline(InputObject *self, PyObject *args)
15121512
{
1513-
long size = -1;
1513+
apr_off_t size = -1;
15141514

15151515
PyObject *result = NULL;
15161516
char *buffer = NULL;
1517-
apr_size_t length = 0;
1517+
apr_off_t length = 0;
15181518

15191519
apr_int64_t n;
15201520

@@ -2251,12 +2251,12 @@ static int Adapter_output(AdapterObject *self, const char *data,
22512251
ap_set_content_type(r, apr_pstrdup(r->pool, value));
22522252
}
22532253
else if (!strcasecmp(name, "Content-Length")) {
2254-
char *v = value;
2255-
long l = 0;
2254+
char *endstr;
2255+
apr_off_t length;
2256+
2257+
if (wsgi_strtoff(&length, value, &endstr, 10)
2258+
|| *endstr || length < 0) {
22562259

2257-
errno = 0;
2258-
l = strtol(v, &v, 10);
2259-
if (*v || errno == ERANGE || l < 0) {
22602260
PyErr_SetString(PyExc_ValueError,
22612261
"invalid content length");
22622262

@@ -2268,10 +2268,10 @@ static int Adapter_output(AdapterObject *self, const char *data,
22682268
return 0;
22692269
}
22702270

2271-
ap_set_content_length(r, l);
2271+
ap_set_content_length(r, length);
22722272

22732273
self->content_length_set = 1;
2274-
self->content_length = l;
2274+
self->content_length = length;
22752275
}
22762276
else if (!strcasecmp(name, "WWW-Authenticate")) {
22772277
apr_table_add(r->err_headers_out, name, value);
@@ -2971,7 +2971,7 @@ static int Adapter_run(AdapterObject *self, PyObject *object)
29712971
PyObject *event = NULL;
29722972

29732973
const char *msg = NULL;
2974-
long length = 0;
2974+
apr_off_t length = 0;
29752975

29762976
WSGIThreadInfo *thread_handle = NULL;
29772977

@@ -4034,6 +4034,12 @@ static int wsgi_execute_script(request_rec *r)
40344034
apr_thread_mutex_unlock(wsgi_module_lock);
40354035
#endif
40364036

4037+
/* Clear startup timeout and prevent from running again. */
4038+
4039+
#if defined(MOD_WSGI_WITH_DAEMONS)
4040+
wsgi_startup_shutdown_time = -1;
4041+
#endif
4042+
40374043
/* Assume an internal server error unless everything okay. */
40384044

40394045
status = HTTP_INTERNAL_SERVER_ERROR;
@@ -4098,12 +4104,6 @@ static int wsgi_execute_script(request_rec *r)
40984104
}
40994105

41004106
Py_XDECREF((PyObject *)adapter);
4101-
4102-
/* Clear startup timeout and prevent from running again. */
4103-
4104-
#if defined(MOD_WSGI_WITH_DAEMONS)
4105-
wsgi_startup_shutdown_time = -1;
4106-
#endif
41074107
}
41084108
else {
41094109
Py_BEGIN_ALLOW_THREADS
@@ -10491,12 +10491,12 @@ static apr_status_t wsgi_socket_send(apr_socket_t *sock, const char *buf,
1049110491
}
1049210492

1049310493
static apr_status_t wsgi_socket_sendv_limit(apr_socket_t *sock,
10494-
struct iovec *vec, int nvec)
10494+
struct iovec *vec, size_t nvec)
1049510495
{
1049610496
apr_status_t rv;
1049710497
apr_size_t written = 0;
1049810498
apr_size_t to_write = 0;
10499-
int i, offset;
10499+
size_t i, offset;
1050010500

1050110501
/* Calculate how much has to be sent. */
1050210502

@@ -10547,7 +10547,7 @@ static apr_status_t wsgi_socket_sendv_limit(apr_socket_t *sock,
1054710547
}
1054810548

1054910549
static apr_status_t wsgi_socket_sendv(apr_socket_t *sock, struct iovec *vec,
10550-
int nvec)
10550+
size_t nvec)
1055110551
{
1055210552
#if defined(_SC_IOV_MAX)
1055310553
static size_t iov_max = 0;

src/server/wsgi_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
#define MOD_WSGI_MAJORVERSION_NUMBER 4
2727
#define MOD_WSGI_MINORVERSION_NUMBER 5
28-
#define MOD_WSGI_MICROVERSION_NUMBER 8
29-
#define MOD_WSGI_VERSION_STRING "4.5.9"
28+
#define MOD_WSGI_MICROVERSION_NUMBER 10
29+
#define MOD_WSGI_VERSION_STRING "4.5.10"
3030

3131
/* ------------------------------------------------------------------------- */
3232

0 commit comments

Comments
 (0)