Hello community, here is the log from the commit of package uwsgi for openSUSE:Factory checked in at 2016-02-17 10:26:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/uwsgi (Old) and /work/SRC/openSUSE:Factory/.uwsgi.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "uwsgi" Changes: -------- --- /work/SRC/openSUSE:Factory/uwsgi/uwsgi.changes 2015-11-12 19:41:00.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.uwsgi.new/uwsgi.changes 2016-02-17 12:25:58.000000000 +0100 @@ -1,0 +2,42 @@ +Thu Jan 7 13:50:57 UTC 2016 - [email protected] + +- Udate to version 2.0.12 + * Bugfixes + * ‘rpcvar’ routing action correctly returns NEXT on empty response + * uwsgiconfig: fix handling of empty keys in python3 (Simone Basso) + * plugins/alarm_speech: fix AppKit spelling to support + case-sensitive filesystems (Andrew Janke) + * Fix inheriting INET address 0.0.0.0 (INADA Naoki) + * core/xmlconf: correctly initialize libxml2 (Riccardo Magliocchetti) + * Pass LIBDIR to linker in python plugin (Borys Pierov) + * Platforms-related build fixes for pty, forkptyrouter and mono + plugins (Jonas Smedegaard and Riccardo Magliocchetti) + * New Features + * The custom worker api - Finally you are able to override the uWSGI + processing model to completeley get control of it. + https://github.com/unbit/uwsgi-docs/blob/master/WorkerOverride.rst + * --wsgi-disable-file-wrapper - This option disables the wsgi.file_wrapper + optimization of the WSGI standard. IN some corner case this is + the only trick to avoid errors. + * Official PHP7 support - PHP 7 is now officially supported in + the php plugin. + * uwsgi.spooler_get_task api (Credits: Alexandre Bonnetain) + This patch allows you to easily parse spooler files. + * --if-hostname-match (Credits: Alexandre Bonnetain) + This options for config logic allows you to define options only + when a regexp over the hostname machtes. +- Update patch 1 - uwsgi-1.9.17-no-LD_RUN_PATH.patch - renamed patch + file to uwsgi-2.0.12-no-LD_RUN_PATH.patch + +------------------------------------------------------------------- +Fri Nov 6 17:33:31 UTC 2015 - [email protected] + +- Update to version 2.0.11.2 + * Bugfixes + * OSX 10.11 supports TCP_FASTOPEN + * fixed http-socket parser state after harakiri + * fixed threaded request logger + * fixed fastrouter subscriptions modifiers + * fixed alarm backlog + +------------------------------------------------------------------- Old: ---- uwsgi-1.9.17-no-LD_RUN_PATH.patch uwsgi-2.0.11.1.tar.gz New: ---- uwsgi-2.0.12-no-LD_RUN_PATH.patch uwsgi-2.0.12.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ uwsgi.spec ++++++ --- /var/tmp/diff_new_pack.YzcCeJ/_old 2016-02-17 12:25:59.000000000 +0100 +++ /var/tmp/diff_new_pack.YzcCeJ/_new 2016-02-17 12:25:59.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package uwsgi # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: uwsgi -Version: 2.0.11.1 +Version: 2.0.12 Release: 0 Summary: Application Container Server for Networked/Clustered Web Applications License: GPL-2.0-with-GCC-exception @@ -35,7 +35,7 @@ # PATCH-FIX-OPENSUSE uwsgi-1.9.17-plugin_build_path.patch - Don't attempt to install plugins to target dest during build Patch0: uwsgi-1.9.17-plugin_build_path.patch # PATCH-FIX-OPENSUSE uwsgi-1.9.17-no-LD_RUN_PATH.patch - Disable invalid rpath in plugins -Patch1: uwsgi-1.9.17-no-LD_RUN_PATH.patch +Patch1: uwsgi-2.0.12-no-LD_RUN_PATH.patch # PATCH-FIX-OPENSUSE uwsgi-1.9.13-objc_gc-no-fobjc-gc.patch - No -fobjc-gc in CFLAGS, which is incorrect in GNU Patch2: uwsgi-1.9.13-objc_gc-no-fobjc-gc.patch # PATCH-FIX-OPENSUSE uwsgi-1.9.11-systemd_logger-old_systemd.patch - Older systemd in 12.2 does not implicity include syslog.h ++++++ uwsgi-1.9.17-no-LD_RUN_PATH.patch -> uwsgi-2.0.12-no-LD_RUN_PATH.patch ++++++ --- /work/SRC/openSUSE:Factory/uwsgi/uwsgi-1.9.17-no-LD_RUN_PATH.patch 2013-09-26 11:53:05.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.uwsgi.new/uwsgi-2.0.12-no-LD_RUN_PATH.patch 2016-02-17 12:25:58.000000000 +0100 @@ -1,6 +1,6 @@ ---- a/plugins/jvm/uwsgiplugin.py -+++ b/plugins/jvm/uwsgiplugin.py -@@ -59,11 +59,6 @@ if "-framework JavaVM" in JVM_LIBPATH: +--- a/plugins/jvm/uwsgiplugin.py 2015-12-30 10:08:49.000000000 +0100 ++++ b/plugins/jvm/uwsgiplugin.py 2016-01-07 14:35:31.212291749 +0100 +@@ -65,11 +65,6 @@ if "-framework JavaVM" in JVM_LIBPATH: GCC_LIST = ['jvm_plugin'] @@ -12,32 +12,30 @@ def post_build(config): if os.system("javac %s/plugins/jvm/uwsgi.java" % os.getcwd()) != 0: os._exit(1) ---- a/plugins/php/uwsgiplugin.py -+++ b/plugins/php/uwsgiplugin.py -@@ -17,7 +17,6 @@ LDFLAGS = os.popen(PHPPATH + ' --ldflags +--- a/plugins/php/uwsgiplugin.py 2015-12-30 10:08:49.000000000 +0100 ++++ b/plugins/php/uwsgiplugin.py 2016-01-07 14:36:47.403974902 +0100 +@@ -19,7 +19,6 @@ LDFLAGS = os.popen(PHPPATH + ' --ldflags if ld_run_path: LDFLAGS.append('-L%s' % ld_run_path) - os.environ['LD_RUN_PATH'] = ld_run_path - LIBS = [os.popen(PHPPATH + ' --libs').read().rstrip(), '-lphp5'] + LIBS = [os.popen(PHPPATH + ' --libs').read().rstrip(), '-lphp' + php_version] ---- a/plugins/python/uwsgiplugin.py -+++ b/plugins/python/uwsgiplugin.py -@@ -44,10 +44,8 @@ if not 'UWSGI_PYTHON_NOLIB' in os.enviro - else: - try: - LDFLAGS.append("-L%s" % sysconfig.get_config_var('LIBDIR')) -- os.environ['LD_RUN_PATH'] = "%s" % (sysconfig.get_config_var('LIBDIR')) - except: - LDFLAGS.append("-L%s/lib" % sysconfig.PREFIX) -- os.environ['LD_RUN_PATH'] = "%s/lib" % sysconfig.PREFIX +--- a/plugins/python/uwsgiplugin.py 2015-12-30 10:08:49.000000000 +0100 ++++ b/plugins/python/uwsgiplugin.py 2016-01-07 14:39:06.071398672 +0100 +@@ -58,8 +58,6 @@ if not 'UWSGI_PYTHON_NOLIB' in os.enviro + LDFLAGS.append("-L%s" % libdir) + LDFLAGS.append("-Wl,-rpath=%s" % libdir) +- os.environ['LD_RUN_PATH'] = "%s" % libdir +- LIBS.append('-lpython%s' % get_python_version()) else: ---- a/plugins/rack/uwsgiplugin.py -+++ b/plugins/rack/uwsgiplugin.py -@@ -44,7 +44,6 @@ LIBS = os.popen(RUBYPATH + " -e \"requir + LIBS = [] +--- a/plugins/rack/uwsgiplugin.py 2015-12-30 10:08:49.000000000 +0100 ++++ b/plugins/rack/uwsgiplugin.py 2016-01-07 14:40:18.623097398 +0100 +@@ -46,7 +46,6 @@ LIBS = os.popen(RUBYPATH + " -e \"requir if has_shared == 'yes': LDFLAGS.append('-L' + libpath ) @@ -45,8 +43,8 @@ LIBS.append(os.popen(RUBYPATH + " -e \"require 'rbconfig';print '-l' + %s::CONFIG['RUBY_SO_NAME']\"" % rbconfig).read().rstrip()) else: rubylibdir = os.popen(RUBYPATH + " -e \"require 'rbconfig';print RbConfig::CONFIG['rubylibdir']\"").read().rstrip() ---- a/plugins/ruby19/uwsgiplugin.py -+++ b/plugins/ruby19/uwsgiplugin.py +--- a/plugins/ruby19/uwsgiplugin.py 2015-12-30 10:08:49.000000000 +0100 ++++ b/plugins/ruby19/uwsgiplugin.py 2016-01-07 14:40:51.614960446 +0100 @@ -40,6 +40,5 @@ LDFLAGS = os.popen(RUBYPATH + " -e \"req libpath = os.popen(RUBYPATH + " -e \"require 'rbconfig';print %s::CONFIG['libdir']\"" % rbconfig).read().rstrip() ++++++ uwsgi-2.0.11.1.tar.gz -> uwsgi-2.0.12.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/.gitignore new/uwsgi-2.0.12/.gitignore --- old/uwsgi-2.0.11.1/.gitignore 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/.gitignore 2015-12-30 10:08:49.000000000 +0100 @@ -16,6 +16,7 @@ /core/config_py.c /t/ring/target +/t/spooler/spooldir/uwsgi_* core/dot_h.c diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/core/config.c new/uwsgi-2.0.12/core/config.c --- old/uwsgi-2.0.11.1/core/config.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/core/config.c 2015-12-30 10:08:49.000000000 +0100 @@ -314,6 +314,24 @@ return 0; } +#ifdef UWSGI_PCRE +int uwsgi_logic_opt_if_hostname_match(char *key, char *value) { + if (uwsgi_regexp_match_pattern(uwsgi.logic_opt_data, uwsgi.hostname)) { + add_exported_option(key, uwsgi_substitute(value, "%(_)", uwsgi.logic_opt_data), 0); + return 1; + } + return 0; +} + +int uwsgi_logic_opt_if_not_hostname_match(char *key, char *value) { + if (!uwsgi_regexp_match_pattern(uwsgi.logic_opt_data, uwsgi.hostname)) { + add_exported_option(key, uwsgi_substitute(value, "%(_)", uwsgi.logic_opt_data), 0); + return 1; + } + return 0; +} +#endif + int uwsgi_count_options(struct uwsgi_option *uopt) { struct uwsgi_option *aopt; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/core/logging.c new/uwsgi-2.0.12/core/logging.c --- old/uwsgi-2.0.11.1/core/logging.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/core/logging.c 2015-12-30 10:08:49.000000000 +0100 @@ -1511,6 +1511,7 @@ if (uwsgi.req_log_master) { logpoll[1].events = POLLIN; logpoll[1].fd = uwsgi.shared->worker_req_log_pipe[0]; + logpolls++; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/core/master.c new/uwsgi-2.0.12/core/master.c --- old/uwsgi-2.0.11.1/core/master.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/core/master.c 2015-12-30 10:08:49.000000000 +0100 @@ -258,17 +258,18 @@ if (uwsgi_sock->queue > backlog) { backlog = uwsgi_sock->queue; } + if (uwsgi_sock->queue > 0 && uwsgi_sock->queue >= uwsgi_sock->max_queue) { uwsgi_log_verbose("*** uWSGI listen queue of socket \"%s\" (fd: %d) full !!! (%llu/%llu) ***\n", uwsgi_sock->name, uwsgi_sock->fd, (unsigned long long) uwsgi_sock->queue, (unsigned long long) uwsgi_sock->max_queue); - } - if (uwsgi.alarm_backlog) { - char buf[1024]; - int ret = snprintf(buf, 1024, "listen queue of socket \"%s\" (fd: %d) full !!! (%llu/%llu)", uwsgi_sock->name, uwsgi_sock->fd, (unsigned long long) uwsgi_sock->queue, (unsigned long long) uwsgi_sock->max_queue); - if (ret > 0 && ret < 1024) { - struct uwsgi_string_list *usl = NULL; - uwsgi_foreach(usl, uwsgi.alarm_backlog) { - uwsgi_alarm_trigger(usl->value, buf, ret); + if (uwsgi.alarm_backlog) { + char buf[1024]; + int ret = snprintf(buf, 1024, "listen queue of socket \"%s\" (fd: %d) full !!! (%llu/%llu)", uwsgi_sock->name, uwsgi_sock->fd, (unsigned long long) uwsgi_sock->queue, (unsigned long long) uwsgi_sock->max_queue); + if (ret > 0 && ret < 1024) { + struct uwsgi_string_list *usl = NULL; + uwsgi_foreach(usl, uwsgi.alarm_backlog) { + uwsgi_alarm_trigger(usl->value, buf, ret); + } } } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/core/master_utils.c new/uwsgi-2.0.12/core/master_utils.c --- old/uwsgi-2.0.11.1/core/master_utils.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/core/master_utils.c 2015-12-30 10:08:49.000000000 +0100 @@ -704,6 +704,7 @@ for(i=0;i<uwsgi.cores;i++) { uwsgi.workers[uwsgi.mywid].cores[i].in_request = 0; memset(&uwsgi.workers[uwsgi.mywid].cores[i].req, 0, sizeof(struct wsgi_request)); + memset(uwsgi.workers[uwsgi.mywid].cores[i].buffer, 0, sizeof(struct uwsgi_header)); } uwsgi_fixup_fds(wid, 0, NULL); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/core/socket.c new/uwsgi-2.0.12/core/socket.c --- old/uwsgi-2.0.11.1/core/socket.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/core/socket.c 2015-12-30 10:08:49.000000000 +0100 @@ -710,6 +710,11 @@ if (uwsgi.tcp_fast_open) { #ifdef TCP_FASTOPEN + + #ifndef SOL_TCP + #define SOL_TCP IPPROTO_TCP + #endif + if (setsockopt(serverfd, SOL_TCP, TCP_FASTOPEN, (const void *) &uwsgi.tcp_fast_open, sizeof(int)) < 0) { uwsgi_error("TCP_FASTOPEN setsockopt()"); } @@ -1169,7 +1174,7 @@ } } else { - match = strcmp(computed_addr, uwsgi_sock->name); + match = uwsgi_socket_strcmp(computed_addr, uwsgi_sock->name); } } if (!match) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/core/spooler.c new/uwsgi-2.0.12/core/spooler.c --- old/uwsgi-2.0.11.1/core/spooler.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/core/spooler.c 2015-12-30 10:08:49.000000000 +0100 @@ -516,6 +516,60 @@ } } +int uwsgi_spooler_read_header(char *task, int spool_fd, struct uwsgi_header *uh) { + + // check if the file is locked by another process + if (uwsgi_fcntl_is_locked(spool_fd)) { + uwsgi_protected_close(spool_fd); + return -1; + } + + // unlink() can destroy the lock !!! + if (access(task, R_OK|W_OK)) { + uwsgi_protected_close(spool_fd); + return -1; + } + + ssize_t rlen = uwsgi_protected_read(spool_fd, uh, 4); + + if (rlen != 4) { + // it could be here for broken file or just opened one + if (rlen < 0) + uwsgi_error("spooler_manage_task()/read()"); + uwsgi_protected_close(spool_fd); + return -1; + } + +#ifdef __BIG_ENDIAN__ + uh->pktsize = uwsgi_swap16(uh->pktsize); +#endif + + return 0; +} + +int uwsgi_spooler_read_content(int spool_fd, char *spool_buf, char **body, size_t *body_len, struct uwsgi_header *uh, struct stat *sf_lstat) { + + if (uwsgi_protected_read(spool_fd, spool_buf, uh->pktsize) != uh->pktsize) { + uwsgi_error("spooler_manage_task()/read()"); + uwsgi_protected_close(spool_fd); + return 1; + } + + // body available ? + if (sf_lstat->st_size > (uh->pktsize + 4)) { + *body_len = sf_lstat->st_size - (uh->pktsize + 4); + *body = uwsgi_malloc(*body_len); + if ((size_t) uwsgi_protected_read(spool_fd, *body, *body_len) != *body_len) { + uwsgi_error("spooler_manage_task()/read()"); + uwsgi_protected_close(spool_fd); + free(*body); + return 1; + } + } + + return 0; +} + void spooler_manage_task(struct uwsgi_spooler *uspool, char *dir, char *task) { int i, ret; @@ -569,53 +623,15 @@ return; } - // check if the file is locked by another process - if (uwsgi_fcntl_is_locked(spool_fd)) { - uwsgi_protected_close(spool_fd); + if (uwsgi_spooler_read_header(task, spool_fd, &uh)) return; - } - - // unlink() can destroy the lock !!! - if (access(task, R_OK | W_OK)) { - uwsgi_protected_close(spool_fd); - return; - } - - ssize_t rlen = uwsgi_protected_read(spool_fd, &uh, 4); - if (rlen != 4) { - // it could be here for broken file or just opened one - if (rlen < 0) - uwsgi_error("read()"); - uwsgi_protected_close(spool_fd); - return; - } - -#ifdef __BIG_ENDIAN__ - uh.pktsize = uwsgi_swap16(uh.pktsize); -#endif - - if (uwsgi_protected_read(spool_fd, spool_buf, uh.pktsize) != uh.pktsize) { - uwsgi_error("read()"); + if (uwsgi_spooler_read_content(spool_fd, spool_buf, &body, &body_len, &uh, &sf_lstat)) { destroy_spool(dir, task); - uwsgi_protected_close(spool_fd); return; } - // body available ? - if (sf_lstat.st_size > (uh.pktsize + 4)) { - body_len = sf_lstat.st_size - (uh.pktsize + 4); - body = uwsgi_malloc(body_len); - if ((size_t) uwsgi_protected_read(spool_fd, body, body_len) != body_len) { - uwsgi_error("read()"); - destroy_spool(dir, task); - uwsgi_protected_close(spool_fd); - free(body); - return; - } - } - - // now the task is running and should not be waken up + // now the task is running and should not be woken up uspool->running = 1; if (!uwsgi.spooler_quiet) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/core/utils.c new/uwsgi-2.0.12/core/utils.c --- old/uwsgi-2.0.11.1/core/utils.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/core/utils.c 2015-12-30 10:08:49.000000000 +0100 @@ -2297,6 +2297,15 @@ return url; } +int uwsgi_regexp_match_pattern(char *pattern, char *str) { + + pcre *regexp; + pcre_extra *regexp_extra; + + if (uwsgi_regexp_build(pattern, ®exp, ®exp_extra)) + return 1; + return !uwsgi_regexp_match(regexp, regexp_extra, str, strlen(str)); +} #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/core/uwsgi.c new/uwsgi-2.0.12/core/uwsgi.c --- old/uwsgi-2.0.11.1/core/uwsgi.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/core/uwsgi.c 2015-12-30 10:08:49.000000000 +0100 @@ -123,9 +123,14 @@ {"if-hostname", required_argument, 0, "(opt logic) check for hostname", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_hostname, UWSGI_OPT_IMMEDIATE}, {"if-not-hostname", required_argument, 0, "(opt logic) check for hostname", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_not_hostname, UWSGI_OPT_IMMEDIATE}, - {"if-exists", required_argument, 0, "(opt logic) check for file/directory existance", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_exists, UWSGI_OPT_IMMEDIATE}, - {"if-not-exists", required_argument, 0, "(opt logic) check for file/directory existance", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_not_exists, UWSGI_OPT_IMMEDIATE}, - {"ifexists", required_argument, 0, "(opt logic) check for file/directory existance", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_exists, UWSGI_OPT_IMMEDIATE}, +#ifdef UWSGI_PCRE + {"if-hostname-match", required_argument, 0, "(opt logic) try to match hostname against a regular expression", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_hostname_match, UWSGI_OPT_IMMEDIATE}, + {"if-not-hostname-match", required_argument, 0, "(opt logic) try to match hostname against a regular expression", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_not_hostname_match, UWSGI_OPT_IMMEDIATE}, +#endif + + {"if-exists", required_argument, 0, "(opt logic) check for file/directory existence", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_exists, UWSGI_OPT_IMMEDIATE}, + {"if-not-exists", required_argument, 0, "(opt logic) check for file/directory existence", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_not_exists, UWSGI_OPT_IMMEDIATE}, + {"ifexists", required_argument, 0, "(opt logic) check for file/directory existence", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_exists, UWSGI_OPT_IMMEDIATE}, {"if-plugin", required_argument, 0, "(opt logic) check for plugin", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_plugin, UWSGI_OPT_IMMEDIATE}, {"if-not-plugin", required_argument, 0, "(opt logic) check for plugin", uwsgi_opt_logic, (void *) uwsgi_logic_opt_if_not_plugin, UWSGI_OPT_IMMEDIATE}, @@ -300,7 +305,7 @@ {"queue", required_argument, 0, "enable shared queue", uwsgi_opt_set_int, &uwsgi.queue_size, 0}, - {"queue-blocksize", required_argument, 0, "set queue blocksize", uwsgi_opt_set_int, &uwsgi.queue_store_sync, 0}, + {"queue-blocksize", required_argument, 0, "set queue blocksize", uwsgi_opt_set_int, &uwsgi.queue_blocksize, 0}, {"queue-store", required_argument, 0, "enable persistent queue to disk", uwsgi_opt_set_str, &uwsgi.queue_store, UWSGI_OPT_MASTER}, {"queue-store-sync", required_argument, 0, "set frequency of sync for persistent queue", uwsgi_opt_set_int, &uwsgi.queue_store_sync, 0}, @@ -557,7 +562,7 @@ {"no-orphans", no_argument, 0, "automatically kill workers if master dies (can be dangerous for availability)", uwsgi_opt_true, &uwsgi.no_orphans, 0}, {"prio", required_argument, 0, "set processes/threads priority", uwsgi_opt_set_rawint, &uwsgi.prio, 0}, {"cpu-affinity", required_argument, 0, "set cpu affinity", uwsgi_opt_set_int, &uwsgi.cpu_affinity, 0}, - {"post-buffering", required_argument, 0, "enable post buffering", uwsgi_opt_set_64bit, &uwsgi.post_buffering, 0}, + {"post-buffering", required_argument, 0, "set size in bytes after which will buffer to disk instead of memory", uwsgi_opt_set_64bit, &uwsgi.post_buffering, 0}, {"post-buffering-bufsize", required_argument, 0, "set buffer size for read() in post buffering mode", uwsgi_opt_set_64bit, &uwsgi.post_buffering_bufsize, 0}, {"body-read-warning", required_argument, 0, "set the amount of allowed memory allocation (in megabytes) for request body before starting printing a warning", uwsgi_opt_set_64bit, &uwsgi.body_read_warning, 0}, {"upload-progress", required_argument, 0, "enable creation of .json files in the specified directory during a file upload", uwsgi_opt_set_str, &uwsgi.upload_progress, 0}, @@ -3372,6 +3377,25 @@ exit(1); } + // must be run before running apps + + // check for worker override + for (i = 0; i < 256; i++) { + if (uwsgi.p[i]->worker) { + if (uwsgi.p[i]->worker()) { + _exit(0); + } + } + } + + for (i = 0; i < uwsgi.gp_cnt; i++) { + if (uwsgi.gp[i]->worker) { + if (uwsgi.gp[i]->worker()) { + _exit(0); + } + } + } + uwsgi_worker_run(); // never here _exit(0); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/core/xmlconf.c new/uwsgi-2.0.12/core/xmlconf.c --- old/uwsgi-2.0.11.1/core/xmlconf.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/core/xmlconf.c 2015-12-30 10:08:49.000000000 +0100 @@ -22,6 +22,8 @@ char *xml_content; size_t xml_size = 0; + LIBXML_TEST_VERSION + if (uwsgi_check_scheme(filename)) { colon = uwsgi_get_last_char(filename, '/'); colon = uwsgi_get_last_char(colon, ':'); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/alarm_speech/uwsgiplugin.py new/uwsgi-2.0.12/plugins/alarm_speech/uwsgiplugin.py --- old/uwsgi-2.0.11.1/plugins/alarm_speech/uwsgiplugin.py 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/alarm_speech/uwsgiplugin.py 2015-12-30 10:08:49.000000000 +0100 @@ -7,7 +7,7 @@ LDFLAGS = [] if uwsgi_os == "Darwin": CFLAGS = [] - LIBS = ['-framework appkit'] + LIBS = ['-framework AppKit'] else: CFLAGS = ['-I /usr/include/GNUstep'] LIBS = [] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/fastrouter/fastrouter.c new/uwsgi-2.0.12/plugins/fastrouter/fastrouter.c --- old/uwsgi-2.0.11.1/plugins/fastrouter/fastrouter.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/fastrouter/fastrouter.c 2015-12-30 10:08:49.000000000 +0100 @@ -222,8 +222,8 @@ peer->can_retry = 0; // fix modifiers - peer->in->buf[0] = peer->modifier1; - peer->in->buf[3] = peer->modifier2; + peer->session->main_peer->in->buf[0] = peer->modifier1; + peer->session->main_peer->in->buf[3] = peer->modifier2; // prepare to write the uwsgi packet peer->out = peer->session->main_peer->in; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/forkptyrouter/forkptyrouter.c new/uwsgi-2.0.12/plugins/forkptyrouter/forkptyrouter.c --- old/uwsgi-2.0.11.1/plugins/forkptyrouter/forkptyrouter.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/forkptyrouter/forkptyrouter.c 2015-12-30 10:08:49.000000000 +0100 @@ -16,14 +16,14 @@ extern struct uwsgi_server uwsgi; -#if defined(__linux__) || defined(__GNU_kFreeBSD__) +#if defined(__linux__) || defined(__GNU_kFreeBSD__) || defined(__HURD__) #include <pty.h> #elif defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) #include <util.h> -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) #include <libutil.h> #endif -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__DragonFly__) #include <utmp.h> #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/forkptyrouter/uwsgiplugin.py new/uwsgi-2.0.12/plugins/forkptyrouter/uwsgiplugin.py --- old/uwsgi-2.0.11.1/plugins/forkptyrouter/uwsgiplugin.py 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/forkptyrouter/uwsgiplugin.py 2015-12-30 10:08:49.000000000 +0100 @@ -1,7 +1,13 @@ +import os +uwsgi_os = os.uname()[0] + NAME='forkptyrouter' CFLAGS = [] LDFLAGS = [] -LIBS = [] +if uwsgi_os in ('Linux', 'FreeBSD', 'GNU', 'NetBSD', 'DragonFly'): + LIBS = ['-lutil'] +else: + LIBS = [] REQUIRES = ['corerouter'] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/mono/mono_plugin.c new/uwsgi-2.0.12/plugins/mono/mono_plugin.c --- old/uwsgi-2.0.11.1/plugins/mono/mono_plugin.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/mono/mono_plugin.c 2015-12-30 10:08:49.000000000 +0100 @@ -611,7 +611,7 @@ // SIGPWR, SIGXCPU: these are used internally by the GC and pthreads. sigset_t smask; sigemptyset(&smask); -#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) +#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__GNU_kFreeBSD__) sigaddset(&smask, SIGXFSZ); #else sigaddset(&smask, SIGPWR); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/php/common.h new/uwsgi-2.0.12/plugins/php/common.h --- old/uwsgi-2.0.11.1/plugins/php/common.h 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/php/common.h 2015-12-30 10:08:49.000000000 +0100 @@ -3,7 +3,11 @@ #include "php_main.h" #include "php_variables.h" +#if (PHP_MAJOR_VERSION < 7) #include "ext/standard/php_smart_str.h" +#else +#define UWSGI_PHP7 +#endif #include "ext/standard/info.h" #include "ext/session/php_session.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/php/php_plugin.c new/uwsgi-2.0.12/plugins/php/php_plugin.c --- old/uwsgi-2.0.11.1/plugins/php/php_plugin.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/php/php_plugin.c 2015-12-30 10:08:49.000000000 +0100 @@ -65,7 +65,11 @@ }; +#ifdef UWSGI_PHP7 +static size_t sapi_uwsgi_ub_write(const char *str, size_t str_length TSRMLS_DC) +#else static int sapi_uwsgi_ub_write(const char *str, uint str_length TSRMLS_DC) +#endif { struct wsgi_request *wsgi_req = (struct wsgi_request *) SG(server_context); @@ -111,7 +115,11 @@ return SAPI_HEADER_SENT_SUCCESSFULLY; } +#ifdef UWSGI_PHP7 +static size_t sapi_uwsgi_read_post(char *buffer, size_t count_bytes TSRMLS_DC) +#else static int sapi_uwsgi_read_post(char *buffer, uint count_bytes TSRMLS_DC) +#endif { uint read_bytes = 0; @@ -235,7 +243,11 @@ } PHP_FUNCTION(uwsgi_version) { +#ifdef UWSGI_PHP7 + RETURN_STRING(UWSGI_VERSION); +#else RETURN_STRING(UWSGI_VERSION, 1); +#endif } PHP_FUNCTION(uwsgi_worker_id) { @@ -321,7 +333,11 @@ if (value) { char *ret = estrndup(value, valsize); free(value); +#ifdef UWSGI_PHP7 + RETURN_STRING(ret); +#else RETURN_STRING(ret, 0); +#endif } RETURN_NULL(); } @@ -425,7 +441,11 @@ // here we do not free varargs for performance reasons char *ret = estrndup(response, size); free(response); +#ifdef UWSGI_PHP7 + RETURN_STRING(ret); +#else RETURN_STRING(ret, 0); +#endif } clear: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/php/session.c new/uwsgi-2.0.12/plugins/php/session.c --- old/uwsgi-2.0.11.1/plugins/php/session.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/php/session.c 2015-12-30 10:08:49.000000000 +0100 @@ -12,21 +12,34 @@ PS_READ_FUNC(uwsgi) { char *cache = PS_GET_MOD_DATA(); uint64_t valsize = 0; - char *value = uwsgi_cache_magic_get((char *)key, strlen(key), &valsize, NULL, cache); +#ifdef UWSGI_PHP7 + char *value = uwsgi_cache_magic_get(key->val, key->len , &valsize, NULL, cache); +#else + char *value = uwsgi_cache_magic_get((char *)key, strlen((char *)key), &valsize, NULL, cache); +#endif if (!value) return FAILURE; +#ifdef UWSGI_PHP7 + *val = zend_string_init(value, valsize, 0); +#else char *new_val = emalloc(valsize); memcpy(new_val, value, valsize); free(value); *val = new_val; *vallen = valsize; +#endif return SUCCESS; } PS_WRITE_FUNC(uwsgi) { char *cache = PS_GET_MOD_DATA(); +#ifdef UWSGI_PHP7 + if (val->len == 0) return SUCCESS; + if (!uwsgi_cache_magic_set(key->val, key->len, val->val, val->len, 0, UWSGI_CACHE_FLAG_UPDATE, cache)) { +#else if (vallen == 0) return SUCCESS; if (!uwsgi_cache_magic_set((char *)key, strlen(key), (char *)val, vallen, 0, UWSGI_CACHE_FLAG_UPDATE, cache)) { +#endif return SUCCESS; } return FAILURE; @@ -34,7 +47,11 @@ PS_DESTROY_FUNC(uwsgi) { char *cache = PS_GET_MOD_DATA(); +#ifdef UWSGI_PHP7 + if (!uwsgi_cache_magic_del(key->val, key->len, cache)) { +#else if (!uwsgi_cache_magic_del((char *)key, strlen(key), cache)) { +#endif return SUCCESS; } return FAILURE; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/php/uwsgiplugin.py new/uwsgi-2.0.12/plugins/php/uwsgiplugin.py --- old/uwsgi-2.0.11.1/plugins/php/uwsgiplugin.py 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/php/uwsgiplugin.py 2015-12-30 10:08:49.000000000 +0100 @@ -12,6 +12,8 @@ PHPPATH = os.environ.get('UWSGICONFIG_PHPPATH', PHPPATH) +php_version = os.popen(PHPPATH + ' --version').read().rstrip().split('.')[0] + CFLAGS = [os.popen(PHPPATH + ' --includes').read().rstrip(), '-Wno-sign-compare'] LDFLAGS = os.popen(PHPPATH + ' --ldflags').read().rstrip().split() @@ -19,7 +21,7 @@ LDFLAGS.append('-L%s' % ld_run_path) os.environ['LD_RUN_PATH'] = ld_run_path -LIBS = [os.popen(PHPPATH + ' --libs').read().rstrip(), '-lphp5'] +LIBS = [os.popen(PHPPATH + ' --libs').read().rstrip(), '-lphp' + php_version] phplibdir = os.environ.get('UWSGICONFIG_PHPLIBDIR') if phplibdir: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/pty/pty.c new/uwsgi-2.0.12/plugins/pty/pty.c --- old/uwsgi-2.0.11.1/plugins/pty/pty.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/pty/pty.c 2015-12-30 10:08:49.000000000 +0100 @@ -1,12 +1,12 @@ #include <uwsgi.h> -#if defined(__linux__) || defined(__GNU_kFreeBSD__) +#if defined(__linux__) || defined(__GNU_kFreeBSD__) || defined(__HURD__) #include <pty.h> #elif defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) #include <util.h> -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) #include <libutil.h> #endif -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__DragonFly__) #include <utmp.h> #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/pty/uwsgiplugin.py new/uwsgi-2.0.12/plugins/pty/uwsgiplugin.py --- old/uwsgi-2.0.11.1/plugins/pty/uwsgiplugin.py 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/pty/uwsgiplugin.py 2015-12-30 10:08:49.000000000 +0100 @@ -5,7 +5,7 @@ CFLAGS = [] LDFLAGS = [] -if uwsgi_os in ('Linux', 'FreeBSD'): +if uwsgi_os in ('Linux', 'FreeBSD', 'GNU', 'NetBSD', 'DragonFly'): LIBS = ['-lutil'] else: LIBS = [] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/python/python_plugin.c new/uwsgi-2.0.12/plugins/python/python_plugin.c --- old/uwsgi-2.0.11.1/plugins/python/python_plugin.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/python/python_plugin.c 2015-12-30 10:08:49.000000000 +0100 @@ -160,6 +160,8 @@ {"wsgi-accept-buffer", no_argument, 0, "accept CPython buffer-compliant objects as WSGI response in addition to string/bytes", uwsgi_opt_true, &up.wsgi_accept_buffer, 0}, {"wsgi-accept-buffers", no_argument, 0, "accept CPython buffer-compliant objects as WSGI response in addition to string/bytes", uwsgi_opt_true, &up.wsgi_accept_buffer, 0}, + {"wsgi-disable-file-wrapper", no_argument, 0, "disable wsgi.file_wrapper feature", uwsgi_opt_true, &up.wsgi_disable_file_wrapper, 0}, + {"python-version", no_argument, 0, "report python version", uwsgi_opt_pyver, NULL, UWSGI_OPT_IMMEDIATE}, {"python-raw", required_argument, 0, "load a python file for managing raw requests", uwsgi_opt_set_str, &up.raw, 0}, @@ -170,6 +172,8 @@ {"py-call-osafterfork", no_argument, 0, "enable child processes running cpython to trap OS signals", uwsgi_opt_true, &up.call_osafterfork, 0}, + {"python-worker-override", required_argument, 0, "override worker with the specified python script", uwsgi_opt_set_str, &up.worker_override, 0}, + {0, 0, 0, 0, 0, 0, 0}, }; @@ -792,6 +796,19 @@ exit(1); } + PyObject *py_sockets_list = PyList_New(0); + struct uwsgi_socket *uwsgi_sock = uwsgi.sockets; + while(uwsgi_sock) { + if (uwsgi_sock->bound) { + PyList_Append(py_sockets_list, PyInt_FromLong(uwsgi_sock->fd)); + } + uwsgi_sock = uwsgi_sock->next; + } + if (PyDict_SetItemString(up.embedded_dict, "sockets", py_sockets_list)) { + PyErr_Print(); + exit(1); + } + PyObject *py_magic_table = PyDict_New(); uint8_t mtk; for (i = 0; i <= 0xff; i++) { @@ -1626,6 +1643,26 @@ Py_DECREF(zero); } +PyObject *uwsgi_python_dict_from_spooler_content(char *filename, char *buf, uint16_t len, char *body, size_t body_len) { + + PyObject *spool_dict = PyDict_New(); + + PyObject *value = PyString_FromString(filename); + PyDict_SetItemString(spool_dict, "spooler_task_name", value); + Py_DECREF(value); + + if (uwsgi_hooked_parse(buf, len, uwsgi_python_add_item, spool_dict)) + return NULL; + + if (body && body_len > 0) { + PyObject *value = PyString_FromStringAndSize(body, body_len); + PyDict_SetItemString(spool_dict, "body", value); + Py_DECREF(value); + } + + return spool_dict; +} + int uwsgi_python_spooler(char *filename, char *buf, uint16_t len, char *body, size_t body_len) { static int random_seed_reset = 0; @@ -1651,25 +1688,15 @@ } int retval = -1; - PyObject *spool_dict = PyDict_New(); PyObject *pyargs = PyTuple_New(1); PyObject *ret = NULL; - PyObject *value = PyString_FromString(filename); - PyDict_SetItemString(spool_dict, "spooler_task_name", value); - Py_DECREF(value); - - if (uwsgi_hooked_parse(buf, len, uwsgi_python_add_item, spool_dict)) { - // malformed packet, destroy it + PyObject *spool_dict = uwsgi_python_dict_from_spooler_content(filename, buf, len, body, body_len); + if (!spool_dict) { retval = -2; goto clear; } - if (body && body_len > 0) { - PyObject *value = PyString_FromStringAndSize(body, body_len); - PyDict_SetItemString(spool_dict, "body", value); - Py_DECREF(value); - } // PyTuple_SetItem steals a reference !!! Py_INCREF(spool_dict); PyTuple_SetItem(pyargs, 0, spool_dict); @@ -1895,6 +1922,22 @@ uwsgi_register_logger("python", uwsgi_python_logger); } +static int uwsgi_python_worker() { + if (!up.worker_override) + return 0; + UWSGI_GET_GIL; + // ensure signals can be used again from python + if (!up.call_osafterfork) + PyOS_AfterFork(); + FILE *pyfile = fopen(up.worker_override, "r"); + if (!pyfile) { + uwsgi_error_open(up.worker_override); + exit(1); + } + PyRun_SimpleFile(pyfile, up.worker_override); + return 1; +} + struct uwsgi_plugin python_plugin = { .name = "python", .alias = "python", @@ -1946,5 +1989,6 @@ .exception_log = uwsgi_python_exception_log, .backtrace = uwsgi_python_backtrace, + .worker = uwsgi_python_worker, }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/python/uwsgi_pymodule.c new/uwsgi-2.0.12/plugins/python/uwsgi_pymodule.c --- old/uwsgi-2.0.11.1/plugins/python/uwsgi_pymodule.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/python/uwsgi_pymodule.c 2015-12-30 10:08:49.000000000 +0100 @@ -2069,6 +2069,58 @@ return ret; } +PyObject *py_uwsgi_spooler_get_task(PyObject * self, PyObject * args) { + + char spool_buf[0xffff]; + struct uwsgi_header uh; + char *body = NULL; + size_t body_len = 0; + + int spool_fd; + + char *task_path = NULL; + + struct stat task_stat; + + if (!PyArg_ParseTuple(args, "s:spooler_get_task", &task_path)) { + return NULL; + } + + if (lstat(task_path, &task_stat)) { + Py_INCREF(Py_None); + return Py_None; + } + + if (access(task_path, R_OK | W_OK)) { + Py_INCREF(Py_None); + return Py_None; + } + + spool_fd = open(task_path, O_RDWR); + + if (spool_fd < 0) { + Py_INCREF(Py_None); + return Py_None; + } + + if (uwsgi_spooler_read_header(task_path, spool_fd, &uh) || + uwsgi_spooler_read_content(spool_fd, spool_buf, &body, &body_len, &uh, &task_stat)) { + Py_INCREF(Py_None); + return Py_None; + } + + uwsgi_protected_close(spool_fd); + + PyObject *spool_dict = uwsgi_python_dict_from_spooler_content(task_path, spool_buf, uh.pktsize, body, body_len); + + if (!spool_dict) { + Py_INCREF(Py_None); + return Py_None; + } + + return spool_dict; +} + PyObject *py_uwsgi_connect(PyObject * self, PyObject * args) { @@ -2502,6 +2554,8 @@ {"spooler_jobs", py_uwsgi_spooler_jobs, METH_VARARGS, ""}, {"spooler_pid", py_uwsgi_spooler_pid, METH_VARARGS, ""}, {"spooler_pids", py_uwsgi_spooler_pids, METH_VARARGS, ""}, + + {"spooler_get_task", py_uwsgi_spooler_get_task, METH_VARARGS, ""}, {NULL, NULL}, }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/python/uwsgi_python.h new/uwsgi-2.0.12/plugins/python/uwsgi_python.h --- old/uwsgi-2.0.11.1/plugins/python/uwsgi_python.h 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/python/uwsgi_python.h 2015-12-30 10:08:49.000000000 +0100 @@ -199,6 +199,10 @@ struct uwsgi_string_list *sharedarea; int call_osafterfork; + + int wsgi_disable_file_wrapper; + + char *worker_override; }; @@ -267,6 +271,8 @@ void init_uwsgi_module_queue(PyObject *); void init_uwsgi_module_snmp(PyObject *); +PyObject *uwsgi_python_dict_from_spooler_content(char *, char *, uint16_t, char *, size_t); + PyObject *uwsgi_pyimport_by_filename(char *, char *); void threaded_swap_ts(struct wsgi_request *, struct uwsgi_app *); @@ -301,6 +307,8 @@ void uwsgi_python_set_thread_name(int); +void uwsgi_python_add_item(char *, uint16_t, char *, uint16_t, void *); + #define py_current_wsgi_req() current_wsgi_req();\ if (!wsgi_req) {\ return PyErr_Format(PyExc_SystemError, "you can call uwsgi api function only from the main callable");\ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/python/uwsgiplugin.py new/uwsgi-2.0.12/plugins/python/uwsgiplugin.py --- old/uwsgi-2.0.11.1/plugins/python/uwsgiplugin.py 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/python/uwsgiplugin.py 2015-12-30 10:08:49.000000000 +0100 @@ -51,11 +51,14 @@ LIBS.append('-lutil') else: try: - LDFLAGS.append("-L%s" % sysconfig.get_config_var('LIBDIR')) - os.environ['LD_RUN_PATH'] = "%s" % (sysconfig.get_config_var('LIBDIR')) + libdir = sysconfig.get_config_var('LIBDIR') except: - LDFLAGS.append("-L%s/lib" % sysconfig.PREFIX) - os.environ['LD_RUN_PATH'] = "%s/lib" % sysconfig.PREFIX + libdir = "%s/lib" % sysconfig.PREFIX + + LDFLAGS.append("-L%s" % libdir) + LDFLAGS.append("-Wl,-rpath=%s" % libdir) + + os.environ['LD_RUN_PATH'] = "%s" % libdir LIBS.append('-lpython%s' % get_python_version()) else: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/python/wsgi_subhandler.c new/uwsgi-2.0.12/plugins/python/wsgi_subhandler.c --- old/uwsgi-2.0.11.1/plugins/python/wsgi_subhandler.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/python/wsgi_subhandler.c 2015-12-30 10:08:49.000000000 +0100 @@ -168,7 +168,8 @@ PyDict_SetItemString(wsgi_req->async_environ, "wsgi.input", wsgi_req->async_input); - PyDict_SetItemString(wsgi_req->async_environ, "wsgi.file_wrapper", wi->sendfile); + if (!up.wsgi_disable_file_wrapper) + PyDict_SetItemString(wsgi_req->async_environ, "wsgi.file_wrapper", wi->sendfile); if (uwsgi.async > 1) { PyDict_SetItemString(wsgi_req->async_environ, "x-wsgiorg.fdevent.readable", wi->eventfd_read); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/plugins/rpc/rpc_plugin.c new/uwsgi-2.0.12/plugins/rpc/rpc_plugin.c --- old/uwsgi-2.0.11.1/plugins/rpc/rpc_plugin.c 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/plugins/rpc/rpc_plugin.c 2015-12-30 10:08:49.000000000 +0100 @@ -477,10 +477,8 @@ uint64_t size; response = uwsgi_do_rpc(remote, func, ur->custom, argv, argvs, &size); free(func); - if (!response) goto end; ret = UWSGI_ROUTE_BREAK; - if (size == 0) goto end; if (!uwsgi_req_append(wsgi_req, ur->data4, ur->data4_len, response, size)) { free(response); @@ -488,7 +486,8 @@ } ret = UWSGI_ROUTE_NEXT; end: - free(response); + if (response) + free(response); for(i=0;i<ur->custom;i++) { if (ubs[i] != NULL) { uwsgi_buffer_destroy(ubs[i]); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/t/spooler/read.py new/uwsgi-2.0.12/t/spooler/read.py --- old/uwsgi-2.0.11.1/t/spooler/read.py 1970-01-01 01:00:00.000000000 +0100 +++ new/uwsgi-2.0.12/t/spooler/read.py 2015-12-30 10:08:49.000000000 +0100 @@ -0,0 +1,32 @@ +# uwsgi --spooler-external t/spooler/spooldir --mule --mule --wsgi-file t/spooler/read.py --http :8080 + +from uwsgidecorators import spoolraw, muleloop + +import uwsgi +import time +import collections +import random +import os + +spooling_directory = uwsgi.opt['spooler-external'] + +@muleloop(1) +def reader(): + c = collections.Counter() + + for file in os.listdir(spooling_directory): + try: + task_dest = uwsgi.spooler_get_task(spooling_directory + "/" + file)["dest"] + c[task_dest] += 1 + except Exception as e: + print(e) + + print(c) + time.sleep(5) + +projects = ["uwsgi", "python", "ruby", "nginx", "memcache"] + +@muleloop(2) +def producer(): + uwsgi.spool(ud_spool_func="consumer", dest=random.choice(projects)) + time.sleep(2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/uwsgi.gemspec new/uwsgi-2.0.12/uwsgi.gemspec --- old/uwsgi-2.0.11.1/uwsgi.gemspec 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/uwsgi.gemspec 2015-12-30 10:08:49.000000000 +0100 @@ -2,7 +2,7 @@ s.name = 'uwsgi' s.license = 'GPL-2' s.version = `python -c "import uwsgiconfig as uc; print uc.uwsgi_version"`.sub(/-dev-.*/,'') - s.date = '2015-07-19' + s.date = '2015-12-30' s.summary = "uWSGI" s.description = "The uWSGI server for Ruby/Rack" s.authors = ["Unbit"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/uwsgi.h new/uwsgi-2.0.12/uwsgi.h --- old/uwsgi-2.0.11.1/uwsgi.h 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/uwsgi.h 2015-12-30 10:08:49.000000000 +0100 @@ -1069,6 +1069,8 @@ void (*vassal)(struct uwsgi_instance *); void (*vassal_before_exec)(struct uwsgi_instance *); + + int (*worker)(void); }; #ifdef UWSGI_PCRE @@ -1077,6 +1079,8 @@ int uwsgi_regexp_match_ovec(pcre *, pcre_extra *, char *, int, int *, int); int uwsgi_regexp_ovector(pcre *, pcre_extra *); char *uwsgi_regexp_apply_ovec(char *, int, char *, int, int *, int); + +int uwsgi_regexp_match_pattern(char *pattern, char *str); #endif @@ -3068,6 +3072,15 @@ void spooler(struct uwsgi_spooler *); pid_t spooler_start(struct uwsgi_spooler *); +int uwsgi_spooler_read_header(char *, int, struct uwsgi_header *); +int uwsgi_spooler_read_content(int, char *, char **, size_t *, struct uwsgi_header *, struct stat *); + +#if defined(_GNU_SOURCE) || defined(__UCLIBC__) +#define uwsgi_versionsort versionsort +#else +int uwsgi_versionsort(const struct dirent **da, const struct dirent **db); +#endif + void uwsgi_curse(int, int); void uwsgi_curse_mule(int, int); void uwsgi_destroy_processes(void); @@ -3837,6 +3850,8 @@ int uwsgi_logic_opt_if_not_plugin(char *, char *); int uwsgi_logic_opt_if_hostname(char *, char *); int uwsgi_logic_opt_if_not_hostname(char *, char *); +int uwsgi_logic_opt_if_hostname_match(char *, char *); +int uwsgi_logic_opt_if_not_hostname_match(char *, char *); void uwsgi_opt_resolve(char *, char *, void *); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/uwsgi-2.0.11.1/uwsgiconfig.py new/uwsgi-2.0.12/uwsgiconfig.py --- old/uwsgi-2.0.11.1/uwsgiconfig.py 2015-07-19 08:17:07.000000000 +0200 +++ new/uwsgi-2.0.12/uwsgiconfig.py 2015-12-30 10:08:49.000000000 +0100 @@ -1,6 +1,6 @@ # uWSGI build system -uwsgi_version = '2.0.11.1' +uwsgi_version = '2.0.12' import os import re @@ -253,9 +253,9 @@ # allow name=path syntax kv = item.split('=') p = kv[0] - if p is None or p == 'None': - continue p = p.strip() + if not p or p == 'None': + continue if p == 'ugreen': if uwsgi_os == 'OpenBSD' or uwsgi_cpu[0:3] == 'arm' or uwsgi_os == 'Haiku' or uwsgi_os.startswith('CYGWIN') or (uwsgi_os == 'Darwin' and uwsgi_os_k.startswith('8')): continue @@ -394,7 +394,7 @@ p = p.strip() path = 'plugins/%s' % p - if p is None or p == 'None': + if not p or p == 'None': continue if p == 'ugreen': @@ -725,7 +725,7 @@ interpolations = {} for option in self.config.options('uwsgi'): - interpolations[option] = self.get(option) + interpolations[option] = self.get(option, default='') iconfig = ConfigParser.ConfigParser(interpolations) iconfig.readfp(open_profile(inherit)) @@ -746,7 +746,7 @@ try: value = self.config.get('uwsgi', key) if value == "" or value == "false": - return None + return default return value except: if default is not None:
