diff --git a/.github/workflows/compile-test.yml b/.github/workflows/compile-test.yml index 2a05e3495..d1ec99799 100644 --- a/.github/workflows/compile-test.yml +++ b/.github/workflows/compile-test.yml @@ -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 }} @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 009d48438..ba0cbbb49 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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 diff --git a/core/cache.c b/core/cache.c index 93da38dfb..661320bf4 100644 --- a/core/cache.c +++ b/core/cache.c @@ -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 { diff --git a/core/ini.c b/core/ini.c index 770819cb9..bb7587157 100644 --- a/core/ini.c +++ b/core/ini.c @@ -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; @@ -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); diff --git a/core/logging.c b/core/logging.c index eb8cfaaee..a5ae67cff 100644 --- a/core/logging.c +++ b/core/logging.c @@ -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; @@ -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 { @@ -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"); } diff --git a/core/master.c b/core/master.c index 7a4b4010c..44d94e26f 100644 --- a/core/master.c +++ b/core/master.c @@ -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__ diff --git a/core/master_checks.c b/core/master_checks.c index 289daa686..6732db15b 100644 --- a/core/master_checks.c +++ b/core/master_checks.c @@ -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 diff --git a/core/utils.c b/core/utils.c index 947c7c47e..26e56aac1 100644 --- a/core/utils.c +++ b/core/utils.c @@ -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); @@ -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]); diff --git a/core/yaml.c b/core/yaml.c index 869c4dc45..c95b5d92a 100644 --- a/core/yaml.c +++ b/core/yaml.c @@ -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 = ""; @@ -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) diff --git a/plugins/php/uwsgiplugin.py b/plugins/php/uwsgiplugin.py index d930c44eb..492926023 100644 --- a/plugins/php/uwsgiplugin.py +++ b/plugins/php/uwsgiplugin.py @@ -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: diff --git a/plugins/python/pyloader.c b/plugins/python/pyloader.c index 8e632ec0f..78f14195a 100644 --- a/plugins/python/pyloader.c +++ b/plugins/python/pyloader.c @@ -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) { diff --git a/uwsgiconfig.py b/uwsgiconfig.py index 968690d39..89d135dbf 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -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