Skip to content

Commit

Permalink
Merge branch 'master' into pcre2
Browse files Browse the repository at this point in the history
  • Loading branch information
xrmx authored Oct 6, 2023
2 parents 0a1eb6b + 0486062 commit b33a0a8
Show file tree
Hide file tree
Showing 17 changed files with 202 additions and 88 deletions.
31 changes: 23 additions & 8 deletions .github/workflows/compile-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,41 @@ on:

jobs:
build:

strategy:
matrix:
libpcre: [libpcre3-dev, libpcre2-dev]
include:
- os: ubuntu-20.04
php: "php7.4"
php-config: "php-config7.4"
libprcre: libpcre3-dev
- os: ubuntu-20.04
php: "php7.4"
php-config: "php-config7.4"
libprcre: libpcre2-dev
- os: ubuntu-22.04
php: "php8.1"
php-config: "php-config8.1"
libprcre: libpcrec3-dev
- os: ubuntu-22.04
php: "php8.1"
php-config: "php-config8.1"
libprcre: libpcre2-dev

runs-on: ubuntu-20.04
runs-on: ${{ matrix.os }}

steps:
- name: remove sury php ppa that does not ship libphpX.Y-embed
run: |
sudo add-apt-repository --remove ppa:ondrej/php
sudo apt remove php7.4-dev php7.4 php7.4-common
sudo apt remove ${{ matrix.php }}-dev ${{ matrix.php }} ${{ matrix.php }}-common
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install --no-install-recommends -qqyf python3.8-dev \
sudo apt install --no-install-recommends -qqyf python3-dev \
libxml2-dev ${{ matrix.libpcre }} libcap2-dev \
libargon2-0-dev libsodium-dev \
php7.4-dev libphp7.4-embed \
liblua5.1-0-dev ruby2.7-dev \
${{ matrix.php }}-dev lib${{ matrix.php }}-embed \
liblua5.1-0-dev ruby-dev \
libjansson-dev libldap2-dev libpq-dev \
libpam0g-dev libsqlite3-dev libyaml-dev \
libzmq3-dev libmatheval-dev libperl-dev \
Expand All @@ -41,7 +56,7 @@ jobs:
curl check
- uses: actions/checkout@v2
- name: Build kitchensink uWSGI binary
run: UWSGICONFIG_PHPPATH=php-config7.4 /usr/bin/python3 uwsgiconfig.py --build travis
run: UWSGICONFIG_PHPPATH=${{ matrix.php-config }} /usr/bin/python3 uwsgiconfig.py --build travis
- name: Build uWSGI binary
run: |
/usr/bin/python3 uwsgiconfig.py --build base
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
test-suite: [unittest, python, deadlocks]
steps:
- name: Add deadnakes ppa
Expand All @@ -24,7 +24,7 @@ jobs:
libpcre2-dev libjansson-dev libcap2-dev \
curl check
- name: Install distutils
if: contains(fromJson('["3.6","3.7","3.8","3.9","3.10","3.11"]'), matrix.python-version)
if: contains(fromJson('["3.6","3.7","3.8","3.9","3.10","3.11","3.12"]'), matrix.python-version)
run: |
sudo apt install --no-install-recommends -qqyf python${{ matrix.python-version }}-distutils \
- uses: actions/checkout@v2
Expand Down
5 changes: 4 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Please remember to substitute XY with proper version.

```
git tag 2.0.XY
git push ---tags origin HEAD
git push --tags origin HEAD
git archive HEAD --prefix uwsgi-2.0.XY/ -o uwsgi-2.0.XY.tar.gz
```

Expand All @@ -25,3 +25,6 @@ Then the tarball must be uploaded to pypi with:
```
python3 -m twine upload uwsgi-2.0.XY.tar.gz
```

Once the file is uploaded the `Download.rst` page of [uwsgi-docs repository](https://github.com/unbit/uwsgi-docs)
should be updated.
5 changes: 0 additions & 5 deletions core/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ struct uwsgi_lock_item *uwsgi_lock_fast_init(char *id) {
}

#ifdef EOWNERDEAD
#ifndef PTHREAD_MUTEX_ROBUST
#define PTHREAD_MUTEX_ROBUST PTHREAD_MUTEX_ROBUST_NP
#define pthread_mutexattr_setrobust pthread_mutexattr_setrobust_np
#define pthread_mutex_consistent pthread_mutex_consistent_np
#endif
if (uwsgi_pthread_robust_mutexes_enabled) {
int ret;
if ((ret = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT)) != 0) {
Expand Down
18 changes: 13 additions & 5 deletions plugins/asyncio/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from distutils import sysconfig
try:
from distutils import sysconfig
paths = [
sysconfig.get_python_inc(),
sysconfig.get_python_inc(plat_specific=True),
]
except ImportError:
import sysconfig
paths = [
sysconfig.get_path('include'),
sysconfig.get_path('platinclude'),
]

NAME = 'asyncio'

CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True)
]
CFLAGS = ['-I' + path for path in paths]
LDFLAGS = []
LIBS = []
GCC_LIST = ['asyncio']
18 changes: 13 additions & 5 deletions plugins/gevent/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from distutils import sysconfig
try:
from distutils import sysconfig
paths = [
sysconfig.get_python_inc(),
sysconfig.get_python_inc(plat_specific=True),
]
except ImportError:
import sysconfig
paths = [
sysconfig.get_path('include'),
sysconfig.get_path('platinclude'),
]

NAME = 'gevent'

CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True)
]
CFLAGS = ['-I' + path for path in paths]
LDFLAGS = []
LIBS = []

Expand Down
18 changes: 13 additions & 5 deletions plugins/greenlet/uwsgiplugin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from distutils import sysconfig
try:
from distutils import sysconfig
paths = [
sysconfig.get_python_inc(),
sysconfig.get_python_inc(plat_specific=True),
]
except ImportError:
import sysconfig
paths = [
sysconfig.get_path('include'),
sysconfig.get_path('platinclude'),
]

NAME = 'greenlet'

CFLAGS = [
'-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True)
]
CFLAGS = ['-I' + path for path in paths]
LDFLAGS = []
LIBS = []

Expand Down
2 changes: 1 addition & 1 deletion plugins/jvm/uwsgiplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
for jvm in known_jvms:
if os.path.exists(jvm + '/include'):
JVM_INCPATH = ["-I%s/include/" % jvm, "-I%s/include/%s" % (jvm, operating_system)]
if os.path.exists("%s/jre"):
if os.path.exists("%s/jre" % jvm):
JVM_LIBPATH = ["-L%s/jre/lib/%s/server" % (jvm, arch)]
else:
JVM_LIBPATH = ["-L%s/lib/server" % (jvm,)]
Expand Down
18 changes: 10 additions & 8 deletions plugins/php/php_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct uwsgi_php {
char *fallback;
char *fallback2;
char *fallback_qs;
char *ini_entries;
size_t ini_size;
int dump_config;
char *server_software;
Expand Down Expand Up @@ -232,21 +233,22 @@ static sapi_module_struct uwsgi_sapi_module;

void uwsgi_php_append_config(char *filename) {
size_t file_size = 0;
char *file_content = uwsgi_open_and_read(filename, &file_size, 1, NULL);
uwsgi_sapi_module.ini_entries = realloc(uwsgi_sapi_module.ini_entries, uphp.ini_size + file_size);
memcpy(uwsgi_sapi_module.ini_entries + uphp.ini_size, file_content, file_size);
char *file_content = uwsgi_open_and_read(filename, &file_size, 1, NULL);
uphp.ini_entries = realloc(uphp.ini_entries, uphp.ini_size + file_size);
memcpy(uphp.ini_entries + uphp.ini_size, file_content, file_size);
uphp.ini_size += file_size-1;
free(file_content);
uwsgi_sapi_module.ini_entries = uphp.ini_entries;
}

void uwsgi_php_set(char *opt) {

uwsgi_sapi_module.ini_entries = realloc(uwsgi_sapi_module.ini_entries, uphp.ini_size + strlen(opt)+2);
memcpy(uwsgi_sapi_module.ini_entries + uphp.ini_size, opt, strlen(opt));

uphp.ini_entries = realloc(uphp.ini_entries, uphp.ini_size + strlen(opt)+2);
memcpy(uphp.ini_entries + uphp.ini_size, opt, strlen(opt));
uphp.ini_size += strlen(opt)+1;
uwsgi_sapi_module.ini_entries[uphp.ini_size-1] = '\n';
uwsgi_sapi_module.ini_entries[uphp.ini_size] = 0;
uphp.ini_entries[uphp.ini_size-1] = '\n';
uphp.ini_entries[uphp.ini_size] = 0;
uwsgi_sapi_module.ini_entries = uphp.ini_entries;
}

extern ps_module ps_mod_uwsgi;
Expand Down
74 changes: 54 additions & 20 deletions plugins/python/python_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,21 @@ void uwsgi_python_pthread_child(void) {
PyMethodDef uwsgi_spit_method[] = { {"uwsgi_spit", py_uwsgi_spit, METH_VARARGS, ""} };
PyMethodDef uwsgi_write_method[] = { {"uwsgi_write", py_uwsgi_write, METH_VARARGS, ""} };

PyDoc_STRVAR(uwsgi_py_doc, "uWSGI api module.");

#ifdef PYTHREE
static PyModuleDef uwsgi_module3 = {
PyModuleDef_HEAD_INIT,
"uwsgi",
uwsgi_py_doc,
-1,
NULL,
};
PyObject *init_uwsgi3(void) {
return PyModule_Create(&uwsgi_module3);
}
#endif

int uwsgi_python_init() {

char *pyversion = strchr(Py_GetVersion(), '\n');
Expand Down Expand Up @@ -298,6 +313,9 @@ int uwsgi_python_init() {
wchar_t *pname = uwsgi_calloc(sizeof(wchar_t) * (strlen(program_name)+1));
mbstowcs(pname, program_name, strlen(program_name)+1);
Py_SetProgramName(pname);
#ifdef UWSGI_PY312
PyImport_AppendInittab("uwsgi", init_uwsgi3);
#endif
#else
Py_SetProgramName(program_name);
#endif
Expand Down Expand Up @@ -660,21 +678,6 @@ void init_uwsgi_vars() {



PyDoc_STRVAR(uwsgi_py_doc, "uWSGI api module.");

#ifdef PYTHREE
static PyModuleDef uwsgi_module3 = {
PyModuleDef_HEAD_INIT,
"uwsgi",
uwsgi_py_doc,
-1,
NULL,
};
PyObject *init_uwsgi3(void) {
return PyModule_Create(&uwsgi_module3);
}
#endif

void init_uwsgi_embedded_module() {
PyObject *new_uwsgi_module, *zero;
int i;
Expand All @@ -695,7 +698,9 @@ void init_uwsgi_embedded_module() {


#ifdef PYTHREE
#ifndef UWSGI_PY312
PyImport_AppendInittab("uwsgi", init_uwsgi3);
#endif
new_uwsgi_module = PyImport_AddModule("uwsgi");
#else
new_uwsgi_module = Py_InitModule3("uwsgi", NULL, uwsgi_py_doc);
Expand Down Expand Up @@ -1208,7 +1213,10 @@ void uwsgi_python_init_apps() {

// prepare for stack suspend/resume
if (uwsgi.async > 0) {
#ifdef UWSGI_PY311
#ifdef UWSGI_PY312
up.current_c_recursion_remaining = uwsgi_malloc(sizeof(int)*uwsgi.async);
up.current_py_recursion_remaining = uwsgi_malloc(sizeof(int)*uwsgi.async);
#elif defined UWSGI_PY311
up.current_recursion_remaining = uwsgi_malloc(sizeof(int)*uwsgi.async);
#else
up.current_recursion_depth = uwsgi_malloc(sizeof(int)*uwsgi.async);
Expand Down Expand Up @@ -1360,7 +1368,12 @@ void uwsgi_python_pre_uwsgi_fork() {
// Acquire the gil and import lock before forking in order to avoid
// deadlocks in workers
UWSGI_GET_GIL
#if defined UWSGI_PY312
PyInterpreterState *interp = PyInterpreterState_Get();
_PyImport_AcquireLock(interp);
#else
_PyImport_AcquireLock();
#endif
}
}

Expand All @@ -1372,7 +1385,12 @@ void uwsgi_python_post_uwsgi_fork(int step) {
if (uwsgi.has_threads) {
if (step == 0) {
// Release locks within master process
#if defined UWSGI_PY312
PyInterpreterState *interp = PyInterpreterState_Get();
_PyImport_ReleaseLock(interp);
#else
_PyImport_ReleaseLock();
#endif
UWSGI_RELEASE_GIL
}
else {
Expand Down Expand Up @@ -1643,7 +1661,11 @@ void uwsgi_python_suspend(struct wsgi_request *wsgi_req) {
PyGILState_Release(pgst);

if (wsgi_req) {
#ifdef UWSGI_PY311
#ifdef UWSGI_PY312
up.current_c_recursion_remaining[wsgi_req->async_id] = tstate->c_recursion_remaining;
up.current_py_recursion_remaining[wsgi_req->async_id] = tstate->py_recursion_remaining;
up.current_frame[wsgi_req->async_id] = tstate->cframe;
#elif defined UWSGI_PY311
up.current_recursion_remaining[wsgi_req->async_id] = tstate->recursion_remaining;
up.current_frame[wsgi_req->async_id] = tstate->cframe;
#else
Expand All @@ -1652,7 +1674,11 @@ void uwsgi_python_suspend(struct wsgi_request *wsgi_req) {
#endif
}
else {
#ifdef UWSGI_PY311
#ifdef UWSGI_PY312
up.current_main_c_recursion_remaining = tstate->c_recursion_remaining;
up.current_main_py_recursion_remaining = tstate->py_recursion_remaining;
up.current_main_frame = tstate->cframe;
#elif defined UWSGI_PY311
up.current_main_recursion_remaining = tstate->recursion_remaining;
up.current_main_frame = tstate->cframe;
#else
Expand Down Expand Up @@ -1886,7 +1912,11 @@ void uwsgi_python_resume(struct wsgi_request *wsgi_req) {
PyGILState_Release(pgst);

if (wsgi_req) {
#ifdef UWSGI_PY311
#ifdef UWSGI_PY312
tstate->c_recursion_remaining = up.current_c_recursion_remaining[wsgi_req->async_id];
tstate->py_recursion_remaining = up.current_py_recursion_remaining[wsgi_req->async_id];
tstate->cframe = up.current_frame[wsgi_req->async_id];
#elif defined UWSGI_PY311
tstate->recursion_remaining = up.current_recursion_remaining[wsgi_req->async_id];
tstate->cframe = up.current_frame[wsgi_req->async_id];
#else
Expand All @@ -1895,7 +1925,11 @@ void uwsgi_python_resume(struct wsgi_request *wsgi_req) {
#endif
}
else {
#ifdef UWSGI_PY311
#ifdef UWSGI_PY312
tstate->c_recursion_remaining = up.current_main_c_recursion_remaining;
tstate->py_recursion_remaining = up.current_main_py_recursion_remaining;
tstate->cframe = up.current_main_frame;
#elif defined UWSGI_PY311
tstate->recursion_remaining = up.current_main_recursion_remaining;
tstate->cframe = up.current_main_frame;
#else
Expand Down
Loading

0 comments on commit b33a0a8

Please sign in to comment.