Compare commits

...
60 Commits
Author SHA1 Message Date
Dimitri John Ledkov a6005624af paste_loader: allow specifying alternative section name to load. 2015-10-09 15:53:52 +01:00
unbit 70198991fe Merge pull request #1045 from Darvame/patch-7
lua_plugin: protected and unprotected __tostring
2015-10-01 07:44:17 +02:00
Darvame Hleran df0c2ca1c8 lua_plugin: cache numbers set/update support 2015-09-29 13:26:48 +03:00
Hleran da60423252 lua_plugin: cache_num, proper error type
- cache_num
and also swiched to wrong type for error status (tested with proper one, than ... "oh wait, we have empty 'i' variable!", later ... "oh sh size_t is uint!")
2015-09-29 00:31:24 +03:00
Hleran 5b9e2b5f39 lua_plugin: counting sid from 1
lua does not like count from 0
2015-09-23 17:07:04 +03:00
Hleran 8185b97030 lua_plugin: protected and unprotected __tostring
- protected and unprotected __tostring (protected outside, unprotected internal, avoid double pcall)
- also check userdata for metafields (non simple type)
- mywid and mysid are functions now
- minor api bump
2015-09-23 14:21:39 +03:00
unbit abac960e62 Merge pull request #1043 from multiSnow/master
also remove all master fifo if vacuum is true
2015-09-21 07:29:29 +02:00
multisnow 8ea8a33d0c also remove all master fifo if vacuum is true 2015-09-21 00:56:06 +08:00
unbit 8939fd5e1b Merge pull request #852 from xtfxme/binary_argc
introduce uwsgi.binary_argc
2015-09-17 19:39:36 +02:00
C Anthony Risinger 849a85b250 Introduce uwsgi.binary_argc
If more than uwsgi.binary_path is needed to make uWSGI self-referential on
reload, plugins can use this field to skip processing of N initial arguments.

eg. if uWSGI is embedded in a host application or interpreter::

    python -B -E -m uwsgi --socket=:8000 --show-config [...]

argv[1:5] are intended for Python, and not for processing by uWSGI, even though
uWSGI might want to manage it (process name). The arguments also cannot just be
ignored because they are crucial for proper reloads.
2015-09-17 04:00:20 -05:00
unbit d08275ea12 Merge pull request #1040 from Darvame/patch-6
lua_plugin: queue segfault
2015-09-16 17:06:45 +02:00
Unbit fb3628d729 attempt to fix http parser 2015-09-16 16:07:45 +02:00
Hleran 52ea02acad Fix 1039: lua_plugin queue segfault
lua stack iterator is not suitable for c arrays
2015-09-16 12:22:25 +03:00
unbit 59a76bb85c Merge pull request #999 from Darvame/patch-5
lua_plugin: new stuff
2015-09-15 07:38:11 +02:00
unbit 26bd4aa489 Merge pull request #522 from ncopa/master
fix building with musl libc
2015-09-15 07:34:34 +02:00
Hleran 7e601d6d8d lua_plugin: cache_exists_multi, no false pls
return nil instead of false
2015-09-13 07:01:12 +03:00
Hleran c2e83fe01d lua_plugin: last
fixes, fixes, removing unnecessary stuff
2015-09-13 06:24:26 +03:00
Unbit 281c1f5427 added Rump unikernel preliminary support 2015-09-10 11:27:43 +02:00
Unbit 33df0dbcc9 attempt to fix #1034 2015-09-10 09:35:53 +02:00
unbit cd24b11369 Merge pull request #1033 from xrmx/solaris11
Fix compilation with solaris 11
2015-09-10 08:34:56 +02:00
Riccardo Magliocchetti bbdf4bbab3 Fix compilation with solaris 11
Based on original patch from Nathan Tamblyn.

Fix #831
2015-09-09 18:28:58 +02:00
Hleran 637ead553a lua_plugin: mule: posible segfault, chunked_read
websocket_send __tostring metatable
2015-09-04 01:55:34 +03:00
Hleran 5ebc399cce lua_plugin: better mules 2015-09-03 00:45:51 +03:00
Unbit e55ac57e07 fixed #1026 2015-09-01 22:25:21 +02:00
Hleran f03f679a5c lua_plugin: mules, cache som fixes 2015-08-31 21:49:13 +03:00
Hleran 72ae69090a lua_plugin: cache_get, cache_get_tmulti
cache_get, cache_get_tmulti
returns key-value table
2015-08-30 02:01:59 +03:00
Hleran 1d595be2d9 lua_plugin: cleanup, more queues, more cache
and loop of nested tables inside headers
2015-08-27 23:15:29 +03:00
unbit 095c75055f Merge pull request #1021 from Ashald/patch-1
Pass LIBDIR to linker in Python plugin
2015-08-27 06:34:36 +02:00
Roberto De Ioris 20a0be1897 worker logger implementation #894 2015-08-27 05:43:04 +02:00
Borys Pierov 637952d048 Pass LIBDIR to linker in python plugin
To make it compile properly when LD_RUN_PATH is ignored.
2015-08-26 19:18:21 -04:00
Hleran a7181572e6 lua_plugin: queues, extend wsapi
dunno why so many additions and deletions
basic queues, remove cache_set_tables (cache_set will do it now)
extend wsapi with 4th argument without breaking it
2015-08-26 19:36:59 +03:00
unbit 920d94c055 Merge pull request #1016 from operasoftware/statsd-dont-send-workers
Add no-workers option to statsd plugin
2015-08-25 18:13:28 +02:00
Marek Wiewiorski 72647fada7 Place check before the lock, and goto to the end of the while block. Instead of strstr use uwsgi_starts_with. 2015-08-25 17:57:57 +02:00
Marek Wiewiorski 82a011e14d Add no-workers option to statsd plugin 2015-08-25 15:58:15 +02:00
Roberto De Ioris 772deaa083 support for single char PATH_INFO, attempt to fix #263 2015-08-25 15:45:25 +02:00
Hleran 94ccb6b030 lua_plugin: mules
separate api, mules
2015-08-22 18:42:41 +03:00
Hleran 01d3133fce lua_plugin: remove atexit, fixes
don't spawn lua_states on workers, if nothing to run
cache multi_set,update,del also returns number of bad keys
remove atexit, does not work as expected
2015-08-21 18:29:04 +03:00
Hleran 377fc2d863 lua_plugin: metric, cache, fixes, cleanups 2015-08-21 01:25:12 +03:00
unbit 59df10466a Merge pull request #1009 from yueyoum/patch-spooler-signal-as-task
Patch spooler signal as task
2015-08-19 17:14:59 +02:00
yueyoum ebb77b55d7 Fix, check spooler_signal_as_task 2015-08-19 17:36:29 +08:00
yueyoum 55c7e653fd fix spooler-signal-as-task 2015-08-19 02:16:54 +08:00
Roberto De Ioris eab664ae8b added -dev to 2.1 version 2015-08-18 19:48:54 +02:00
yueyoum 9a0681a6e0 Merge branch 'test' into patch-spooler-signal-as-task
Introduce a new param: spooler-signal-as-task
In present, the spooler-max-tasks only works for spool tasks
With this patch, the signal based events (cron, timer)
can also be treated as tasks.
When reach the spooler-max-tasks limits,
the spool process will restart.

This helps for alleviate memory leaks
2015-08-19 00:21:40 +08:00
yueyoum cd69e718aa spooler-signal-as-task 2015-08-19 00:19:03 +08:00
Hleran 8d2465db9b lua_plugin: lua_createtable, signals
using prehashed lua_createtable when we can instead of lua_newtable
plugin specific regsiter signal
add_file_monitor, add_timer, add_rb_timer, add_cron, alarm
2015-08-16 15:41:39 +03:00
unbit 69fb3c8426 Merge pull request #1004 from marcan/master
rados plugin: Add username parameter
2015-08-12 16:51:06 +02:00
Hector Martin 7cf499127f rados plugin: Add username parameter 2015-08-12 22:22:42 +09:00
Hleran 6921e8f820 lua_plugin: atexit, lazy signal routing
uwsgi_lua_atexit to commit garbage-collection metamethods
lazy signal routing: empty 'receiver' value on master table
2015-08-07 07:36:13 +03:00
Hleran 37971671cb lua_plugin: own signal ref table in each lua_State 2015-08-07 02:39:44 +03:00
Hleran 271c6aa13b lua_plugin: rpc via uwsgi.rpc_ref table 2015-08-06 19:40:52 +03:00
Hleran c375920c63 lua_plugin: proper uwsgi.log
uwsgi.log like buildin print function
dummy response cfunction
2015-08-06 05:17:20 +03:00
Hleran 8e28051d2e lua_plugin: metatable.__tostring
also can yield and send metatable with __tostring attr;
some cleanups and optimizations;
2015-08-05 23:58:22 +03:00
unbit d5114da3aa Merge pull request #998 from xrmx/systemdfixup
systemd_logger: fix build with recent systemd
2015-08-04 11:19:48 +02:00
Riccardo Magliocchetti 9787f6882c systemd_logger: fix build with recent systemd
Since systemd 209 all the functionalities of libsystemd-* have
been merged in libsystemd.
2015-08-04 11:13:32 +02:00
unbit 7efa3666b7 Merge pull request #820 from xrmx/mimetypedebug
core/static: print mimetype of file in debug print
2015-08-04 10:39:22 +02:00
Natanael Copa 74eb3b282e always define _GNU_SOURCE for linux or GNU libc
We are using various extenstions that the spec say depends on _GNU_SOURCE,
for example unshare, CPU_SET, CPU_ZERO, cpu_set_t. We enable those always
for linux or GNU (kbsd/gnu)

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2015-08-04 09:16:34 +02:00
Natanael Copa 1b59a46fc0 use portable pthread functions instead of the non-portable
The pthread functions pthread_mutexattr_setrobust and
pthread_mutex_consistent are in posix nowdays. Use those instead of their
non-portable synonyms.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2015-08-03 16:37:33 +02:00
Natanael Copa 92672880d7 Check for GNU libc instead of linux for use of execinfo.h
Since execinfo.h is a GNU extension it makes more sense to check for GNU
than to assume that linux is GNU.

This is needed for building on linux with musl libc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2015-08-03 16:37:33 +02:00
Natanael Copa fb9d063e81 define WAIT_ANY if missing
POSIX uses -1 and does not define WAIT_ANY so we need to define it if
needed.

See:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/waitpid.html
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2015-08-03 16:37:33 +02:00
Riccardo Magliocchetti 5e9e07c64f core/static: print mimetype of file on debug print 2015-01-23 11:54:39 +01:00
23 changed files with 2644 additions and 542 deletions
+2 -1
View File
@@ -396,9 +396,10 @@ static int uwsgi_hook_chown2(char *arg) {
}
#ifdef __sun__
#if defined(UWSGI_SUNOS_EXTERN_SETHOSTNAME)
extern int sethostname(char *, int);
#endif
static int uwsgi_hook_hostname(char *arg) {
#ifdef __CYGWIN__
return -1;
+27 -1
View File
@@ -62,6 +62,7 @@ void uwsgi_init_default() {
uwsgi.cpus = 1;
uwsgi.new_argc = -1;
uwsgi.binary_argc = 1;
uwsgi.backtrace_depth = 64;
uwsgi.max_apps = 64;
@@ -261,11 +262,33 @@ void uwsgi_commandline_config() {
int argc = uwsgi.argc;
char **argv = uwsgi.argv;
// we might want to ignore some arguments not meant for us
char binary_argv0_pretty[256] = {'\0'};
char *binary_argv0_actual = NULL;
if (uwsgi.new_argc > -1 && uwsgi.new_argv) {
argc = uwsgi.new_argc;
argv = uwsgi.new_argv;
}
if (uwsgi.binary_argc > 1 && argc >= uwsgi.binary_argc) {
char *pretty = (char *)binary_argv0_pretty;
strncat(pretty, argv[0], 255);
for (i = 1; i < uwsgi.binary_argc; i++) {
if (strlen(pretty) + 1 + strlen(argv[i]) + 1 > 256)
break;
strcat(pretty, " ");
strcat(pretty, argv[i]);
}
argc -= uwsgi.binary_argc - 1;
argv += uwsgi.binary_argc - 1;
binary_argv0_actual = argv[0];
argv[0] = (char *)binary_argv0_pretty;
}
char *optname;
while ((i = getopt_long(argc, argv, uwsgi.short_options, uwsgi.long_options, &uwsgi.option_index)) != -1) {
@@ -289,6 +312,8 @@ void uwsgi_commandline_config() {
add_exported_option(optname, optarg, 0);
}
if (binary_argv0_actual != NULL)
argv[0] = binary_argv0_actual;
#ifdef UWSGI_DEBUG
uwsgi_log("optind:%d argc:%d\n", optind, uwsgi.argc);
@@ -413,7 +438,8 @@ pid_t uwsgi_daemonize2() {
uwsgi_write_pidfile(uwsgi.pidfile2);
}
if (uwsgi.log_master) uwsgi_setup_log_master();
if (uwsgi.log_master)
uwsgi_setup_log_master();
return uwsgi.mypid;
}
+16 -2
View File
@@ -99,7 +99,7 @@ retry:
uwsgi_log("unable to set PTHREAD_PRIO_INHERIT\n");
exit(1);
}
if (pthread_mutexattr_setrobust_np(&attr, PTHREAD_MUTEX_ROBUST)) {
if (pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST)) {
uwsgi_log("unable to make the mutex 'robust'\n");
exit(1);
}
@@ -161,7 +161,7 @@ void uwsgi_lock_fast(struct uwsgi_lock_item *uli) {
#ifdef EOWNERDEAD
if (pthread_mutex_lock((pthread_mutex_t *) uli->lock_ptr) == EOWNERDEAD) {
uwsgi_log("[deadlock-detector] a process holding a robust mutex died. recovering...\n");
pthread_mutex_consistent_np((pthread_mutex_t *) uli->lock_ptr);
pthread_mutex_consistent((pthread_mutex_t *) uli->lock_ptr);
}
#else
pthread_mutex_lock((pthread_mutex_t *) uli->lock_ptr);
@@ -476,6 +476,20 @@ void uwsgi_rwunlock_fast(struct uwsgi_lock_item *uli) {
#endif
#ifdef __RUMP__
int semctl(int _0, int _1, int _2, ...) {
return 0;
}
int semget(key_t _0, int _1, int _2) {
return 0;
}
int semop(int _0, struct sembuf * _1, size_t _2) {
return 0;
}
#undef UWSGI_LOCK_ENGINE_NAME
#define UWSGI_LOCK_ENGINE_NAME "fake"
#endif
struct uwsgi_lock_item *uwsgi_lock_ipcsem_init(char *id) {
// used by ftok
+14
View File
@@ -1512,6 +1512,7 @@ static void *logger_thread_loop(void *noarg) {
if (uwsgi.req_log_master) {
logpoll[1].events = POLLIN;
logpoll[1].fd = uwsgi.shared->worker_req_log_pipe[0];
logpolls++;
}
@@ -1551,6 +1552,19 @@ void uwsgi_threaded_logger_spawn() {
}
}
void uwsgi_threaded_logger_worker_spawn() {
pthread_t logger_thread;
pthread_mutex_init(&uwsgi.threaded_logger_lock, NULL);
uwsgi.log_master_buf = uwsgi_malloc(uwsgi.log_master_bufsize);
if (pthread_create(&logger_thread, NULL, logger_thread_loop, NULL)) {
uwsgi_error_safe("uwsgi_threaded_logger_worker_spawn()/pthread_create()");
exit(1);
}
}
void uwsgi_register_log_encoder(char *name, char *(*func)(struct uwsgi_log_encoder *, char *, size_t, size_t *)) {
struct uwsgi_log_encoder *old_ule = NULL, *ule = uwsgi.log_encoders;
+1
View File
@@ -772,6 +772,7 @@ int uwsgi_respawn_worker(int wid) {
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);
+1 -1
View File
@@ -715,7 +715,7 @@ next:
}
if (uwsgi.manage_script_name) {
if (uwsgi_apps_cnt > 0 && wsgi_req->path_info_len > 1 && wsgi_req->path_info_pos != -1) {
if (uwsgi_apps_cnt > 0 && wsgi_req->path_info_len >= 1 && wsgi_req->path_info_pos != -1) {
// starts with 1 as the 0 app is the default (/) one
int best_found = 0;
char *orig_path_info = wsgi_req->path_info;
+5 -4
View File
@@ -467,8 +467,7 @@ cycle:
return received_signal;
}
void uwsgi_receive_signal(struct wsgi_request *wsgi_req, int fd, char *name, int id) {
int uwsgi_receive_signal(struct wsgi_request *wsgi_req, int fd, char *name, int id) {
uint8_t uwsgi_signal;
ssize_t ret = read(fd, &uwsgi_signal, 1);
@@ -487,13 +486,15 @@ void uwsgi_receive_signal(struct wsgi_request *wsgi_req, int fd, char *name, int
if (uwsgi_signal_handler(wsgi_req, uwsgi_signal)) {
uwsgi_log_verbose("error managing signal %d on %s %d\n", uwsgi_signal, name, id);
}
return 1;
}
return;
return 0;
destroy:
// better to kill the whole worker...
uwsgi_log_verbose("uWSGI %s %d screams: UAAAAAAH my master disconnected: I will kill myself!!!\n", name, id);
end_me(0);
// never here
return 0;
}
+13 -1
View File
@@ -465,7 +465,15 @@ void spooler(struct uwsgi_spooler *uspool) {
if (event_queue_wait(spooler_event_queue, timeout, &interesting_fd) > 0) {
if (uwsgi.master_process) {
if (interesting_fd == uwsgi.shared->spooler_signal_pipe[1]) {
uwsgi_receive_signal(NULL, interesting_fd, "spooler", (int) getpid());
if (uwsgi_receive_signal(NULL, interesting_fd, "spooler", (int) getpid())) {
if (uwsgi.spooler_signal_as_task) {
uspool->tasks++;
if (uwsgi.spooler_max_tasks > 0 && uspool->tasks >= (uint64_t) uwsgi.spooler_max_tasks) {
uwsgi_log("[spooler %s pid: %d] maximum number of tasks reached (%d) recycling ...\n", uspool->dir, (int) uwsgi.mypid, uwsgi.spooler_max_tasks);
end_me(0);
}
}
}
}
}
}
@@ -488,7 +496,11 @@ static void spooler_scandir(struct uwsgi_spooler *uspool, char *dir) {
if (!dir)
dir = uspool->dir;
#ifdef __NetBSD__
n = scandir(dir, &tasklist, NULL, (void *)uwsgi_versionsort);
#else
n = scandir(dir, &tasklist, NULL, uwsgi_versionsort);
#endif
if (n < 0) {
uwsgi_error("scandir()");
return;
+1 -1
View File
@@ -459,7 +459,7 @@ int uwsgi_real_file_serve(struct wsgi_request *wsgi_req, char *real_filename, si
}
}
#ifdef UWSGI_DEBUG
uwsgi_log("[uwsgi-fileserve] file %s found\n", real_filename);
uwsgi_log("[uwsgi-fileserve] file %s found, mimetype %s\n", real_filename, mime_type);
#endif
// static file - don't update avg_rt after request
+4
View File
@@ -333,9 +333,11 @@ void uwsgi_as_root() {
if (getuid() > 0)
goto nonroot;
#ifndef __RUMP__
if (!uwsgi.master_as_root && !uwsgi.uidname) {
uwsgi_log_initial("uWSGI running as root, you can use --uid/--gid/--chroot options\n");
}
#endif
int in_jail = 0;
@@ -905,9 +907,11 @@ void uwsgi_as_root() {
}
}
#ifndef __RUMP__
if (!getuid()) {
uwsgi_log_initial("*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** \n");
}
#endif
#ifdef UWSGI_CAP
+43 -4
View File
@@ -326,6 +326,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"spooler-processes", required_argument, 0, "set the number of processes for spoolers", uwsgi_opt_set_int, &uwsgi.spooler_numproc, UWSGI_OPT_IMMEDIATE},
{"spooler-quiet", no_argument, 0, "do not be verbose with spooler tasks", uwsgi_opt_true, &uwsgi.spooler_quiet, 0},
{"spooler-max-tasks", required_argument, 0, "set the maximum number of tasks to run before recycling a spooler", uwsgi_opt_set_int, &uwsgi.spooler_max_tasks, 0},
{"spooler-signal-as-task", no_argument, 0, "treat signal events as tasks in spooler, combine used with spooler-max-tasks", uwsgi_opt_true, &uwsgi.spooler_signal_as_task, 0},
{"spooler-harakiri", required_argument, 0, "set harakiri timeout for spooler tasks", uwsgi_opt_set_int, &uwsgi.harakiri_options.spoolers, 0},
{"spooler-frequency", required_argument, 0, "set spooler frequency", uwsgi_opt_set_int, &uwsgi.spooler_frequency, 0},
{"spooler-freq", required_argument, 0, "set spooler frequency", uwsgi_opt_set_int, &uwsgi.spooler_frequency, 0},
@@ -713,6 +714,8 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"req-logger", required_argument, 0, "set/append a request logger", uwsgi_opt_set_req_logger, NULL, UWSGI_OPT_REQ_LOG_MASTER},
{"logger-req", required_argument, 0, "set/append a request logger", uwsgi_opt_set_req_logger, NULL, UWSGI_OPT_REQ_LOG_MASTER},
{"logger", required_argument, 0, "set/append a logger", uwsgi_opt_set_logger, NULL, UWSGI_OPT_MASTER | UWSGI_OPT_LOG_MASTER},
{"worker-logger", required_argument, 0, "set/append a logger in single-worker setup", uwsgi_opt_set_worker_logger, NULL, 0},
{"worker-logger-req", required_argument, 0, "set/append a request logger in single-worker setup", uwsgi_opt_set_req_logger, NULL, 0},
{"logger-list", no_argument, 0, "list enabled loggers", uwsgi_opt_true, &uwsgi.loggers_list, 0},
{"loggers-list", no_argument, 0, "list enabled loggers", uwsgi_opt_true, &uwsgi.loggers_list, 0},
{"threaded-logger", no_argument, 0, "offload log writing to a thread", uwsgi_opt_true, &uwsgi.threaded_logger, UWSGI_OPT_MASTER | UWSGI_OPT_LOG_MASTER},
@@ -720,6 +723,9 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"log-encoder", required_argument, 0, "add an item in the log encoder chain", uwsgi_opt_add_string_list, &uwsgi.requested_log_encoders, UWSGI_OPT_MASTER | UWSGI_OPT_LOG_MASTER},
{"log-req-encoder", required_argument, 0, "add an item in the log req encoder chain", uwsgi_opt_add_string_list, &uwsgi.requested_log_req_encoders, UWSGI_OPT_MASTER | UWSGI_OPT_LOG_MASTER},
{"worker-log-encoder", required_argument, 0, "add an item in the log encoder chain", uwsgi_opt_add_string_list, &uwsgi.requested_log_encoders, 0},
{"worker-log-req-encoder", required_argument, 0, "add an item in the log req encoder chain", uwsgi_opt_add_string_list, &uwsgi.requested_log_req_encoders, 0},
#ifdef UWSGI_PCRE
@@ -1689,6 +1695,18 @@ next:
}
}
}
if (uwsgi.master_fifo) {
// also remove all master fifo
struct uwsgi_string_list *usl;
uwsgi_foreach(usl, uwsgi.master_fifo) {
if (unlink(usl->value)) {
uwsgi_error("unlink()");
}
else {
uwsgi_log("VACUUM: master fifo %s removed.\n", usl->value);
}
}
}
}
}
}
@@ -1832,7 +1850,7 @@ void uwsgi_plugins_atexit(void) {
void uwsgi_backtrace(int depth) {
#if (defined(__linux__) && !defined(__UCLIBC__))|| (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO)
#if (defined(__GLIBC__) && !defined(__UCLIBC__))|| (defined(__APPLE__) && !defined(NO_EXECINFO)) || defined(UWSGI_HAS_EXECINFO)
#include <execinfo.h>
@@ -2080,7 +2098,6 @@ void uwsgi_setup(int argc, char *argv[], char *envp[]) {
int i;
struct utsname uuts;
// signal mask is inherited, and sme process manager could make a real mess...
sigset_t smask;
@@ -2353,6 +2370,13 @@ configure:
// setup master logging
if (uwsgi.log_master)
uwsgi_setup_log_master();
else if (uwsgi.numproc == 1 && uwsgi.log_worker && uwsgi.master_process == 0) {
// hack for allowing request loggers
if (uwsgi.requested_req_logger)
uwsgi.req_log_master = 1;
uwsgi_setup_log_master();
uwsgi_threaded_logger_worker_spawn();
}
// setup offload engines
uwsgi_offload_engines_register_all();
@@ -2435,6 +2459,10 @@ configure:
uwsgi_log_initial("compiled with version: %s on %s\n", __VERSION__, UWSGI_BUILD_DATE);
#ifdef __RUMP__
uwsgi_log_initial("Rump system detected\n");
#else
struct utsname uuts;
#ifdef __sun__
if (uname(&uuts) < 0) {
#else
@@ -2447,6 +2475,7 @@ configure:
uwsgi_log_initial("nodename: %s\n", uuts.nodename);
uwsgi_log_initial("machine: %s\n", uuts.machine);
}
#endif
uwsgi_log_initial("clock source: %s\n", uwsgi.clock->name);
#ifdef UWSGI_PCRE
@@ -2659,10 +2688,13 @@ int uwsgi_start(void *v_argv) {
uwsgi_write_pidfile(uwsgi.pidfile2);
}
#ifndef __RUMP__
if (!uwsgi.master_process && !uwsgi.command_mode) {
uwsgi_log_initial("*** WARNING: you are running uWSGI without its master process manager ***\n");
}
#endif
#ifndef __RUMP__
#ifdef RLIMIT_NPROC
if (uwsgi.rl_nproc.rlim_max > 0) {
uwsgi.rl_nproc.rlim_cur = uwsgi.rl_nproc.rlim_max;
@@ -2682,6 +2714,8 @@ int uwsgi_start(void *v_argv) {
}
}
#endif
#endif
#ifndef __OpenBSD__
if (uwsgi.rl.rlim_max > 0) {
@@ -3856,8 +3890,8 @@ void uwsgi_init_all_apps() {
what++;
for (j = 0; j < 256; j++) {
if (uwsgi.p[j]->mount_app) {
uwsgi_log("mounting %s on %s\n", what, app_mps->value);
if (uwsgi.p[j]->mount_app(app_mps->value, what) != -1)
uwsgi_log("mounting %s on %s\n", what, app_mps->value[0] == 0 ? "/" : app_mps->value);
if (uwsgi.p[j]->mount_app(app_mps->value[0] == 0 ? "/" : app_mps->value, what) != -1)
break;
}
}
@@ -4152,6 +4186,11 @@ void uwsgi_opt_set_logger(char *opt, char *value, void *prefix) {
}
}
void uwsgi_opt_set_worker_logger(char *opt, char *value, void *prefix) {
uwsgi_opt_set_logger(opt, value, prefix);
uwsgi.log_worker = 1;
}
void uwsgi_opt_set_req_logger(char *opt, char *value, void *prefix) {
if (!value)
+2432 -494
View File
File diff suppressed because it is too large Load Diff
+12 -1
View File
@@ -711,7 +711,11 @@ PyObject *uwsgi_paste_loader(void *arg1) {
exit(UWSGI_FAILED_APP_CODE);
}
paste_arg = PyTuple_New(1);
if (up.paste_name) {
paste_arg = PyTuple_New(2);
} else {
paste_arg = PyTuple_New(1);
}
if (!paste_arg) {
PyErr_Print();
exit(UWSGI_FAILED_APP_CODE);
@@ -722,6 +726,13 @@ PyObject *uwsgi_paste_loader(void *arg1) {
exit(UWSGI_FAILED_APP_CODE);
}
if (up.paste_name) {
if (PyTuple_SetItem(paste_arg, 1, UWSGI_PYFROMSTRING(up.paste_name))) {
PyErr_Print();
exit(UWSGI_FAILED_APP_CODE);
}
}
paste_app = PyEval_CallObject(paste_loadapp, paste_arg);
if (!paste_app) {
PyErr_Print();
+7 -3
View File
@@ -149,6 +149,7 @@ struct uwsgi_option uwsgi_python_options[] = {
{"paste", required_argument, 0, "load a paste.deploy config file", uwsgi_opt_set_str, &up.paste, 0},
{"paste-logger", no_argument, 0, "enable paste fileConfig logger", uwsgi_opt_true, &up.paste_logger, 0},
{"paste-name", required_argument, 0, "specify the name of the paste section", uwsgi_opt_set_str, &up.paste_name, 0},
{"web3", required_argument, 0, "load a web3 app", uwsgi_opt_set_str, &up.web3, 0},
@@ -204,15 +205,18 @@ struct uwsgi_option uwsgi_python_options[] = {
/* this routine will be called after each fork to reinitialize the various locks */
void uwsgi_python_pthread_prepare(void) {
pthread_mutex_lock(&up.lock_pyloaders);
if (!up.is_dynamically_loading_an_app)
pthread_mutex_lock(&up.lock_pyloaders);
}
void uwsgi_python_pthread_parent(void) {
pthread_mutex_unlock(&up.lock_pyloaders);
if (!up.is_dynamically_loading_an_app)
pthread_mutex_unlock(&up.lock_pyloaders);
}
void uwsgi_python_pthread_child(void) {
pthread_mutex_init(&up.lock_pyloaders, NULL);
if (!up.is_dynamically_loading_an_app)
pthread_mutex_init(&up.lock_pyloaders, NULL);
}
PyMethodDef uwsgi_spit_method[] = { {"uwsgi_spit", py_uwsgi_spit, METH_VARARGS, ""} };
+1 -2
View File
@@ -11,8 +11,7 @@ extern struct uwsgi_plugin python_plugin;
PyTypeObject uwsgi_RequestContextType = {
PyObject_HEAD_INIT(NULL)
0,
PyVarObject_HEAD_INIT(NULL, 0)
"uwsgi.RequestContext",
sizeof(uwsgi_RequestContext),
0,
+4
View File
@@ -154,6 +154,7 @@ struct uwsgi_python {
char *file_config;
char *paste;
int paste_logger;
char *paste_name;
char *eval;
char *web3;
@@ -213,6 +214,9 @@ struct uwsgi_python {
int call_osafterfork;
int pre_initialized;
// when 1 we have the app-loading lock held
int is_dynamically_loading_an_app;
};
+7 -4
View File
@@ -71,11 +71,14 @@ if 'UWSGI_PYTHON_NOLIB' not in os.environ:
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:
+2
View File
@@ -339,6 +339,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
// this part must be heavy locked in threaded modes
if (uwsgi.threads > 1) {
pthread_mutex_lock(&up.lock_pyloaders);
up.is_dynamically_loading_an_app = 1;
}
}
@@ -363,6 +364,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
if (wsgi_req->dynamic) {
if (uwsgi.threads > 1) {
up.is_dynamically_loading_an_app = 0;
pthread_mutex_unlock(&up.lock_pyloaders);
}
}
+3 -1
View File
@@ -47,6 +47,7 @@ struct uwsgi_rados_mountpoint {
char *allow_delete;
char *allow_mkcol;
char *allow_propfind;
char *username;
};
static struct uwsgi_option uwsgi_rados_options[] = {
@@ -405,6 +406,7 @@ static void uwsgi_rados_add_mountpoint(char *arg, size_t arg_len) {
"allow_delete", &urmp->allow_delete,
"allow_mkcol", &urmp->allow_mkcol,
"allow_propfind", &urmp->allow_propfind,
"username", &urmp->username,
NULL)) {
uwsgi_log("unable to parse rados mountpoint definition\n");
exit(1);
@@ -423,7 +425,7 @@ static void uwsgi_rados_add_mountpoint(char *arg, size_t arg_len) {
uwsgi_log("[rados] mounting %s ...\n", urmp->mountpoint);
rados_t cluster;
if (rados_create(&cluster, NULL) < 0) {
if (rados_create(&cluster, urmp->username) < 0) {
uwsgi_error("can't create Ceph cluster handle");
exit(1);
}
+13
View File
@@ -16,6 +16,14 @@ it exports values exposed by the metric subsystem
extern struct uwsgi_server uwsgi;
struct uwsgi_stats_pusher_statsd {
int no_workers;
} u_stats_pusher_statsd;
static struct uwsgi_option stats_pusher_statsd_options[] = {
{"statsd-no-workers", no_argument, 0, "disable generation of single worker metrics", uwsgi_opt_true, &u_stats_pusher_statsd.no_workers, 0}
};
// configuration of a statsd node
struct statsd_node {
int fd;
@@ -86,6 +94,9 @@ static void stats_pusher_statsd(struct uwsgi_stats_pusher_instance *uspi, time_t
struct uwsgi_buffer *ub = uwsgi_buffer_new(uwsgi.page_size);
struct uwsgi_metric *um = uwsgi.metrics;
while(um) {
if (u_stats_pusher_statsd.no_workers && !uwsgi_starts_with(um->name, um->name_len, "worker.", 7)) {
goto next;
}
uwsgi_rlock(uwsgi.metrics_lock);
// ignore return value
if (um->type == UWSGI_METRIC_GAUGE) {
@@ -100,6 +111,7 @@ static void stats_pusher_statsd(struct uwsgi_stats_pusher_instance *uspi, time_t
*um->value = um->initial_value;
uwsgi_rwunlock(uwsgi.metrics_lock);
}
next:
um = um->next;
}
uwsgi_buffer_destroy(ub);
@@ -114,6 +126,7 @@ static void stats_pusher_statsd_init(void) {
struct uwsgi_plugin stats_pusher_statsd_plugin = {
.name = "stats_pusher_statsd",
.options = stats_pusher_statsd_options,
.on_load = stats_pusher_statsd_init,
};
+2
View File
@@ -3,6 +3,8 @@ import os
NAME = 'systemd_logger'
CFLAGS = os.popen('pkg-config --cflags libsystemd-journal').read().rstrip().split()
CFLAGS += os.popen('pkg-config --cflags libsystemd').read().rstrip().split()
LDFLAGS = []
LIBS = os.popen('pkg-config --libs libsystemd-journal').read().rstrip().split()
LIBS += os.popen('pkg-config --libs libsystemd').read().rstrip().split()
GCC_LIST = ['systemd_logger']
+26 -18
View File
@@ -153,22 +153,7 @@ extern "C" {
#endif
#endif
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <stdio.h>
#ifdef __UCLIBC__
#include <sched.h>
#endif
#undef _GNU_SOURCE
#include <stdlib.h>
#include <stddef.h>
#include <signal.h>
#include <math.h>
#include <sys/types.h>
#ifdef __linux__
#if defined(__linux__) || defined(__GNUC__)
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
@@ -176,6 +161,14 @@ extern "C" {
#define __USE_GNU
#endif
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <signal.h>
#include <math.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#ifdef __linux__
@@ -183,7 +176,6 @@ extern "C" {
#define MSG_FASTOPEN 0x20000000
#endif
#endif
#undef _GNU_SOURCE
#include <netinet/in.h>
#include <termios.h>
@@ -269,6 +261,9 @@ extern int pivot_root(const char *new_root, const char *put_old);
#include <stdint.h>
#include <sys/wait.h>
#ifndef WAIT_ANY
#define WAIT_ANY (-1)
#endif
#ifdef __APPLE__
#ifndef MAC_OS_X_VERSION_MIN_REQUIRED
@@ -344,6 +339,9 @@ extern int pivot_root(const char *new_root, const char *put_old);
#ifdef __sun__
#undef __EXTENSIONS__
#endif
#ifdef _GNU_SOURCE
#undef _GNU_SOURCE
#endif
#define UWSGI_CACHE_FLAG_UNGETTABLE 0x01
#define UWSGI_CACHE_FLAG_UPDATE 1 << 1
@@ -2375,6 +2373,7 @@ struct uwsgi_server {
int spooler_quiet;
int spooler_frequency;
int snmp;
char *snmp_addr;
char *snmp_community;
@@ -2808,6 +2807,13 @@ struct uwsgi_server {
char *emperor_trigger_socket;
int emperor_trigger_socket_fd;
int spooler_signal_as_task;
int log_worker;
// number of args to consider part of binary_path
int binary_argc;
};
struct uwsgi_rpc {
@@ -3800,6 +3806,7 @@ void uwsgi_opt_set_str(char *, char *, void *);
void uwsgi_opt_custom(char *, char *, void *);
void uwsgi_opt_set_null(char *, char *, void *);
void uwsgi_opt_set_logger(char *, char *, void *);
void uwsgi_opt_set_worker_logger(char *, char *, void *);
void uwsgi_opt_set_req_logger(char *, char *, void *);
void uwsgi_opt_set_str_spaced(char *, char *, void *);
void uwsgi_opt_add_string_list(char *, char *, void *);
@@ -4000,7 +4007,7 @@ int uwsgi_is_file2(char *, struct stat *);
int uwsgi_is_dir(char *);
int uwsgi_is_link(char *);
void uwsgi_receive_signal(struct wsgi_request *, int, char *, int);
int uwsgi_receive_signal(struct wsgi_request *, int, char *, int);
void uwsgi_exec_atexit(void);
struct uwsgi_stats {
@@ -4546,6 +4553,7 @@ void uwsgi_master_manage_emperor(void);
void uwsgi_master_manage_udp(int);
void uwsgi_threaded_logger_spawn(void);
void uwsgi_threaded_logger_worker_spawn(void);
void uwsgi_master_check_idle(void);
int uwsgi_master_check_workers_deadline(void);
+8 -4
View File
@@ -1,11 +1,11 @@
# uWSGI build system
uwsgi_version = '2.1'
uwsgi_version = '2.1-dev'
import os
import re
import time
uwsgi_os = os.uname()[0]
uwsgi_os = os.environ.get('UWSGI_FORCE_OS', os.uname()[0])
uwsgi_os_k = re.split('[-+]', os.uname()[2])[0]
uwsgi_os_v = os.uname()[3]
uwsgi_cpu = os.uname()[4]
@@ -31,7 +31,6 @@ GCC = os.environ.get('CC', sysconfig.get_config_var('CC'))
if not GCC:
GCC = 'gcc'
def get_preprocessor():
if 'clang' in GCC:
return 'clang -xc core/clang_fake.c'
@@ -810,7 +809,12 @@ class uConf(object):
self.libs.append('-lsendfile')
self.libs.append('-lrt')
self.gcc_list.append('lib/sun_fixes')
self.ldflags.append('-L/lib')
sunos_major = int(uwsgi_os_k.split('.')[0])
sunos_minor = int(uwsgi_os_k.split('.')[1])
# solaris < 11 does not have sethostname declared in unistd
if not (sunos_major == 5 and sunos_minor > 10):
self.cflags.append('-DUWSGI_SUNOS_EXTERN_SETHOSTNAME')
self.ldflags.append('-L/lib')
if not uwsgi_os_v.startswith('Nexenta'):
self.libs.remove('-rdynamic')