Skip to content

Commit

Permalink
Merge pull request #2601 from xrmx/backport-2024
Browse files Browse the repository at this point in the history
Backport for 2.0.24
  • Loading branch information
xrmx authored Feb 8, 2024
2 parents f9e4f0e + 0cea1d5 commit 239ea68
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 25 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/compile-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ jobs:
- os: ubuntu-20.04
php: "php7.4"
php-config: "php-config7.4"
cc: "gcc"
- os: ubuntu-22.04
php: "php8.1"
php-config: "php-config8.1"
cc: "gcc"
- os: ubuntu-22.04
php: "php8.1"
php-config: "php-config8.1"
cc: "clang"

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

Expand All @@ -43,16 +49,16 @@ jobs:
libcurl4-openssl-dev \
openjdk-11-jdk libgloox-dev gccgo \
cli-common-dev mono-devel mono-mcs uuid-dev \
curl check
- uses: actions/checkout@v2
- name: Build kitchensink uWSGI binary
run: UWSGICONFIG_PHPPATH=${{ matrix.php-config }} /usr/bin/python3 uwsgiconfig.py --build travis
curl check ${{ matrix.cc == 'clang' && 'clang' || '' }}
- uses: actions/checkout@v4
- name: Build kitchensink uWSGI binary with gcc or default with clang
run: CC=${{ matrix.cc }} UWSGICONFIG_PHPPATH=${{ matrix.php-config }} /usr/bin/python3 uwsgiconfig.py --build ${{ matrix.cc == 'gcc' && 'travis' || '' }}
- name: Build uWSGI binary
run: |
/usr/bin/python3 uwsgiconfig.py --build base
CC=${{ matrix.cc }} /usr/bin/python3 uwsgiconfig.py --build base
- name: Build cgi plugin
run: |
/usr/bin/python3 uwsgiconfig.py --plugin plugins/cgi base
CC=${{ matrix.cc }} /usr/bin/python3 uwsgiconfig.py --plugin plugins/cgi base
- name: Build dummy plugin
run: |
/usr/bin/python3 uwsgiconfig.py --plugin plugins/dummy base
CC=${{ matrix.cc }} /usr/bin/python3 uwsgiconfig.py --plugin plugins/dummy base
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
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
- uses: actions/checkout@v4
- name: Run unit tests
if: matrix.test-suite == 'unittest'
run: make tests
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
sudo apt install --no-install-recommends -qqyf python3-dev \
libpcre3-dev libjansson-dev libcap2-dev ruby2.7-dev \
curl check
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Run unit tests
run: make tests
- name: Build uWSGI binary
Expand Down
6 changes: 6 additions & 0 deletions core/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,12 @@ void uwsgi_cache_fix(struct uwsgi_cache *uc) {
if (uci->expires && (!next_scan || next_scan > uci->expires)) {
next_scan = uci->expires;
}
if (!uc->lru_head && !uci->lru_prev) {
uc->lru_head = i;
}
if (!uc->lru_tail && !uci->lru_next) {
uc->lru_tail = i;
}
restored++;
}
else {
Expand Down
3 changes: 0 additions & 3 deletions core/ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ void uwsgi_ini_config(char *file, char *magic_table[]) {
char *key;
char *val;

int lines = 1;

char *section_asked = "uwsgi";
char *colon;
int got_section = 0;
Expand Down Expand Up @@ -130,7 +128,6 @@ void uwsgi_ini_config(char *file, char *magic_table[]) {
if (ini_line == NULL) {
break;
}
lines++;

// skip empty line
key = ini_lstrip(ini);
Expand Down
6 changes: 3 additions & 3 deletions core/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ void uwsgi_logit_simple(struct wsgi_request *wsgi_req) {
}

if (uwsgi.logging_options.memory_report == 1) {
rlen = snprintf(mempkt, 4096, "{address space usage: %lld bytes/%lluMB} {rss usage: %llu bytes/%lluMB} ", (unsigned long long) uwsgi.workers[uwsgi.mywid].vsz_size, (unsigned long long) uwsgi.workers[uwsgi.mywid].vsz_size / 1024 / 1024,
rlen = snprintf(mempkt, 4096, "{address space usage: %llu bytes/%lluMB} {rss usage: %llu bytes/%lluMB} ", (unsigned long long) uwsgi.workers[uwsgi.mywid].vsz_size, (unsigned long long) uwsgi.workers[uwsgi.mywid].vsz_size / 1024 / 1024,
(unsigned long long) uwsgi.workers[uwsgi.mywid].rss_size, (unsigned long long) uwsgi.workers[uwsgi.mywid].rss_size / 1024 / 1024);
logvec[logvecpos].iov_base = mempkt;
logvec[logvecpos].iov_len = rlen;
Expand Down Expand Up @@ -749,7 +749,7 @@ void get_memusage(uint64_t * rss, uint64_t * vsz) {
int i;
procfile = fopen("/proc/self/stat", "r");
if (procfile) {
i = fscanf(procfile, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %llu %lld", (unsigned long long *) vsz, (unsigned long long *) rss);
i = fscanf(procfile, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %llu %llu", (unsigned long long *) vsz, (unsigned long long *) rss);
if (i != 2) {
uwsgi_log("warning: invalid record in /proc/self/stat\n");
} else {
Expand All @@ -763,7 +763,7 @@ void get_memusage(uint64_t * rss, uint64_t * vsz) {
int i;
procfile = fopen("/proc/self/stat", "r");
if (procfile) {
i = fscanf(procfile, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %llu %lld", (unsigned long long *) vsz, (unsigned long long *) rss);
i = fscanf(procfile, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %llu %llu", (unsigned long long *) vsz, (unsigned long long *) rss);
if (i != 2) {
uwsgi_log("warning: invalid record in /proc/self/stat\n");
}
Expand Down
2 changes: 1 addition & 1 deletion core/master.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static void master_check_listen_queue() {
uint64_t backlog = 0;
struct uwsgi_socket *uwsgi_sock = uwsgi.sockets;
while(uwsgi_sock) {
if (uwsgi_sock->family == AF_INET) {
if (uwsgi_sock->family == AF_INET || uwsgi_sock->family == AF_INET6) {
get_tcp_info(uwsgi_sock);
}
#ifdef __linux__
Expand Down
2 changes: 1 addition & 1 deletion core/master_checks.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void uwsgi_master_check_idle() {

}

int uwsgi_master_check_harakiri(int w, int c, int harakiri) {
int uwsgi_master_check_harakiri(int w, int c, time_t harakiri) {
/**
* Triggers a harakiri when the following conditions are met:
* - harakiri timeout > current time
Expand Down
4 changes: 2 additions & 2 deletions core/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -4048,7 +4048,7 @@ void uwsgi_uuid(char *buf) {
uuid_generate(uuid_value);
uuid_unparse(uuid_value, buf);
#else
int i, r[11];
unsigned int i, r[11];
if (!uwsgi_file_exists("/dev/urandom"))
goto fallback;
int fd = open("/dev/urandom", O_RDONLY);
Expand All @@ -4064,7 +4064,7 @@ void uwsgi_uuid(char *buf) {
goto done;
fallback:
for (i = 0; i < 11; i++) {
r[i] = rand();
r[i] = (unsigned int) rand();
}
done:
snprintf(buf, 37, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10]);
Expand Down
2 changes: 0 additions & 2 deletions core/yaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ void uwsgi_yaml_config(char *file, char *magic_table[]) {
#else
int depth;
int current_depth = 0;
int lines = 1;
char *yaml_line;
char *section = "";

Expand All @@ -221,7 +220,6 @@ void uwsgi_yaml_config(char *file, char *magic_table[]) {
if (yaml_line == NULL) {
break;
}
lines++;

// skip empty line
if (yaml[0] == 0)
Expand Down
7 changes: 6 additions & 1 deletion plugins/php/uwsgiplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
LDFLAGS.append('-L%s' % ld_run_path)
os.environ['LD_RUN_PATH'] = ld_run_path

LIBS = [os.popen(PHPPATH + ' --libs').read().rstrip(), '-lphp' + php_version]
# PHP8 and above does not add the version to the library
# name
if int(php_version) < 8:
LIBS = [os.popen(PHPPATH + ' --libs').read().rstrip(), '-lphp' + php_version]
else:
LIBS = [os.popen(PHPPATH + ' --libs').read().rstrip(), '-lphp']

phplibdir = os.environ.get('UWSGICONFIG_PHPLIBDIR')
if phplibdir:
Expand Down
4 changes: 3 additions & 1 deletion plugins/python/pyloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ int init_uwsgi_app(int loader, void *arg1, struct wsgi_request *wsgi_req, PyThre
memset(wi, 0, sizeof(struct uwsgi_app));
wi->modifier1 = python_plugin.modifier1;
wi->mountpoint_len = wsgi_req->appid_len < 0xff ? wsgi_req->appid_len : (0xff-1);
strncpy(wi->mountpoint, wsgi_req->appid, wi->mountpoint_len);
if (wi->mountpoint_len > 0) {
strncpy(wi->mountpoint, wsgi_req->appid, wi->mountpoint_len);
}

// dynamic chdir ?
if (wsgi_req->chdir_len > 0) {
Expand Down
12 changes: 10 additions & 2 deletions uwsgiconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,16 @@ def __init__(self, filename, mute=False):
if 'UWSGI_INCLUDES' in os.environ:
self.include_path += os.environ['UWSGI_INCLUDES'].split(',')


self.cflags = ['-O2', '-I.', '-Wall', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] + os.environ.get("CFLAGS", "").split() + self.get('cflags','').split()
cflags = [
'-O2',
'-I.',
'-Wall',
'-D_LARGEFILE_SOURCE',
'-D_FILE_OFFSET_BITS=64'
]
if "gcc" in GCC:
cflags.append('-Wformat-signedness')
self.cflags = cflags + os.environ.get("CFLAGS", "").split() + self.get('cflags', '').split()

report['kernel'] = uwsgi_os

Expand Down

0 comments on commit 239ea68

Please sign in to comment.