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
30 changed files with 2665 additions and 995 deletions
+3 -177
View File
@@ -8,8 +8,7 @@ The uWSGI Emperor
extern struct uwsgi_server uwsgi;
extern char **environ;
static void emperor_send_stats(int);
static void emperor_manage_command(int);
void emperor_send_stats(int);
time_t emperor_throttle;
int emperor_throttle_level;
@@ -996,11 +995,6 @@ void emperor_respawn(struct uwsgi_instance *c_ui, time_t mod) {
return;
}
// check if we are in suspended mode
if (c_ui->pid == -1 && c_ui->suspended) {
return;
}
// check if we are in on_demand mode (the respawn will be ignored)
if (c_ui->pid == -1 && c_ui->on_demand_fd > -1) {
c_ui->last_mod = mod;
@@ -1141,7 +1135,6 @@ void emperor_add_with_attrs(struct uwsgi_emperor_scanner *ues, char *name, time_
// start without loyalty
n_ui->last_loyal = 0;
n_ui->loyal = 0;
n_ui->suspended = 0;
n_ui->attrs = attrs;
@@ -1159,15 +1152,6 @@ void emperor_add_with_attrs(struct uwsgi_emperor_scanner *ues, char *name, time_
n_ui->pipe_config[0] = -1;
n_ui->pipe_config[1] = -1;
// Check if the Emperor has to wait for a command before spawning a vassal
if (uwsgi.emperor_command_socket) {
if (uwsgi.emperor_wait_for_command && !uwsgi_string_list_has_item(uwsgi.emperor_wait_for_command_ignore, name, strlen(name))) {
n_ui->suspended = 1;
uwsgi_log("[uwsgi-emperor] %s -> \"wait-for-command\" instance detected, waiting for the spawn command ...\n", name);
return;
}
}
// ok here we check if we need to bind to the specified socket or continue with the activation
if (socket_name) {
n_ui->on_demand_fd = on_demand_bind(socket_name);
@@ -1330,7 +1314,7 @@ int uwsgi_emperor_vassal_start(struct uwsgi_instance *n_ui) {
if (uwsgi_hooks_run_and_return(uwsgi.hook_as_emperor_before_vassal, "as-emperor-before-vassal", NULL, 0)) {
return -1;
emperor_del(n_ui);
}
if (uwsgi.zeus) {
@@ -1460,8 +1444,6 @@ int uwsgi_emperor_vassal_start(struct uwsgi_instance *n_ui) {
#if defined(__linux__) && !defined(OBSOLETE_LINUX_KERNEL)
uwsgi_hooks_setns_run(uwsgi.hook_as_emperor_setns, n_ui->pid, n_ui->uid, n_ui->gid);
#endif
// ensure the instance is no more suspended
n_ui->suspended = 0;
return 0;
}
else {
@@ -2054,19 +2036,6 @@ void emperor_loop() {
uwsgi_log("*** Emperor trigger socket enabled on %s fd: %d ***\n", uwsgi.emperor_trigger_socket, uwsgi.emperor_trigger_socket_fd);
}
if (uwsgi.emperor_command_socket) {
char *udp_port = strchr(uwsgi.emperor_command_socket, ':');
if (udp_port) {
uwsgi.emperor_command_socket_fd = bind_to_udp(uwsgi.emperor_command_socket, 0, 0);
}
else {
uwsgi.emperor_command_socket_fd = bind_to_unix_dgram(uwsgi.emperor_command_socket);
}
event_queue_add_fd_read(uwsgi.emperor_queue, uwsgi.emperor_command_socket_fd);
uwsgi_log("*** Emperor command socket enabled on %s fd: %d ***\n", uwsgi.emperor_command_socket, uwsgi.emperor_command_socket_fd);
}
ui = &ui_base;
int freq = 0;
@@ -2132,11 +2101,6 @@ void emperor_loop() {
continue;
}
if (uwsgi.emperor_command_socket && uwsgi.emperor_command_socket_fd > -1 && interesting_fd == uwsgi.emperor_command_socket_fd) {
emperor_manage_command(uwsgi.emperor_command_socket_fd);
continue;
}
// check if a monitor is mapped to that file descriptor
if (uwsgi_emperor_scanner_event(interesting_fd)) {
continue;
@@ -2374,142 +2338,7 @@ recheck:
}
// manage commands sentto the dgram command socket
struct emperor_command {
char *cmd;
uint16_t cmd_len;
char *vassal;
uint16_t vassal_len;
char *msg;
uint16_t msg_len;
};
static void emperor_manage_command_parser(char *key, uint16_t keylen, char *val, uint16_t vallen, void *data) {
struct emperor_command *ec = (struct emperor_command *) data;
if (!uwsgi_strncmp("cmd", 3, key, keylen)) {
ec->cmd = val;
ec->cmd_len = vallen;
}
else if (!uwsgi_strncmp("command", 7, key, keylen)) {
ec->cmd = val;
ec->cmd_len = vallen;
}
else if (!uwsgi_strncmp("vassal", 6, key, keylen)) {
ec->vassal = val;
ec->vassal_len = vallen;
}
else if (!uwsgi_strncmp("msg", 3, key, keylen)) {
ec->msg = val;
ec->msg_len = vallen;
}
}
static void emperor_command_spawn(struct emperor_command *ec) {
if (ec->vassal_len == 0) {
uwsgi_log("[uwsgi-emperor] ERROR: the \"spawn\" command requires a vassal name\n");
return;
}
char *name = uwsgi_concat2n(ec->vassal, ec->vassal_len, "", 0);
struct uwsgi_instance *vassal = emperor_get(name);
if (!vassal) {
uwsgi_log("[uwsgi-emperor] ERROR: unable to find vassal \"%s\"\n", name);
free(name);
return;
}
if (!vassal->suspended) {
uwsgi_log("[uwsgi-emperor] WARNING: the vassal \"%s\" is already active\n", name);
free(name);
return;
}
uwsgi_log("[uwsgi-emperor] INFO: requested the spawn of vassal \"%s\"\n", name);
free(name);
// start the vassal
if (uwsgi_emperor_vassal_start(vassal)) {
// clear the vassal
emperor_del(vassal);
}
}
static void emperor_command_respawn(struct emperor_command *ec) {
if (ec->vassal_len == 0) {
uwsgi_log("[uwsgi-emperor] ERROR: the \"respawn\" command requires a vassal name\n");
return;
}
char *name = uwsgi_concat2n(ec->vassal, ec->vassal_len, "", 0);
struct uwsgi_instance *vassal = emperor_get(name);
if (!vassal) {
uwsgi_log("[uwsgi-emperor] ERROR: unable to find vassal \"%s\"\n", name);
free(name);
return;
}
uwsgi_log("[uwsgi-emperor] INFO: requested the respawn of vassal \"%s\"\n", name);
free(name);
// restart the vassal
emperor_respawn(vassal, uwsgi_now());
}
static void emperor_command_stop(struct emperor_command *ec) {
if (ec->vassal_len == 0) {
uwsgi_log("[uwsgi-emperor] ERROR: the \"stop\" command requires a vassal name\n");
return;
}
char *name = uwsgi_concat2n(ec->vassal, ec->vassal_len, "", 0);
struct uwsgi_instance *vassal = emperor_get(name);
if (!vassal) {
uwsgi_log("[uwsgi-emperor] ERROR: unable to find vassal \"%s\"\n", name);
free(name);
return;
}
uwsgi_log("[uwsgi-emperor] INFO: requested the stop of vassal \"%s\"\n", name);
free(name);
// stop the vassal
emperor_stop(vassal);
}
static void emperor_command_log(struct emperor_command *ec) {
if (ec->msg_len == 0) {
uwsgi_log("[uwsgi-emperor] ERROR: the \"log\" command requires a message\n");
return;
}
uwsgi_log("%.*s\n", ec->msg_len, ec->msg);
}
static void emperor_manage_command(int fd) {
char buf[4096];
ssize_t len = recv(fd, buf, 4096, 0);
if (len <= 0) return;
struct emperor_command ec;
memset(&ec, 0, sizeof(struct emperor_command));
uwsgi_hooked_parse(buf + 4, len - 4, emperor_manage_command_parser, &ec);
if (ec.cmd_len == 0) return;
// spawn a suspended vassal
if (!uwsgi_strncmp(ec.cmd, ec.cmd_len, "spawn", 5)) {
emperor_command_spawn(&ec);
return;
}
// respawn a vassal
if (!uwsgi_strncmp(ec.cmd, ec.cmd_len, "respawn", 7)) {
emperor_command_respawn(&ec);
return;
}
// stop a vassal
if (!uwsgi_strncmp(ec.cmd, ec.cmd_len, "stop", 4)) {
emperor_command_stop(&ec);
return;
}
// log a message
if (!uwsgi_strncmp(ec.cmd, ec.cmd_len, "log", 3)) {
emperor_command_log(&ec);
return;
}
}
static void emperor_send_stats(int fd) {
void emperor_send_stats(int fd) {
struct sockaddr_un client_src;
socklen_t client_src_len = 0;
@@ -2615,9 +2444,6 @@ static void emperor_send_stats(int fd) {
if (uwsgi_stats_keyval_comma(us, "on_demand", c_ui->socket_name ? c_ui->socket_name : ""))
goto end0;
if (uwsgi_stats_keylong_comma(us, "suspended", (unsigned long long) c_ui->suspended))
goto end0;
if (uwsgi_stats_keylong_comma(us, "adopted", (unsigned long long) c_ui->adopted))
goto end0;
+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
+9 -79
View File
@@ -167,14 +167,8 @@ struct uwsgi_subscribe_node *uwsgi_get_subscribe_node(struct uwsgi_subscribe_slo
while (node) {
// is the node alive ?
if (now - node->last_check > uwsgi.subscription_tolerance) {
if (node->death_mark == 0) {
if (node->len > 0) {
uwsgi_log("[uwsgi-subscription for pid %d] %.*s => marking %.*s as failed (no announce received in %d seconds)\n", (int) uwsgi.mypid, (int) keylen, key, (int) node->len, node->name, uwsgi.subscription_tolerance);
}
else if (node->vassal_len > 0) {
uwsgi_log("[uwsgi-subscription for pid %d] %.*s => marking vassal %.*s as failed (no announce received in %d seconds)\n", (int) uwsgi.mypid, (int) keylen, key, (int) node->vassal_len, node->vassal, uwsgi.subscription_tolerance);
}
}
if (node->death_mark == 0)
uwsgi_log("[uwsgi-subscription for pid %d] %.*s => marking %.*s as failed (no announce received in %d seconds)\n", (int) uwsgi.mypid, (int) keylen, key, (int) node->len, node->name, uwsgi.subscription_tolerance);
node->failcnt++;
node->death_mark = 1;
}
@@ -307,10 +301,7 @@ struct uwsgi_subscribe_node *uwsgi_add_subscribe_node(struct uwsgi_subscribe_slo
struct uwsgi_subscribe_slot *current_slot = uwsgi_get_subscribe_slot(slot, usr->key, usr->keylen), *old_slot = NULL, *a_slot;
struct uwsgi_subscribe_node *node, *old_node = NULL;
if ((usr->address_len > 0xff || usr->address_len == 0) && (usr->vassal_len > 0xff || usr->vassal_len == 0))
return NULL;
if (uwsgi.subscription_vassal_required && usr->vassal_len == 0)
if (usr->address_len > 0xff || usr->address_len == 0)
return NULL;
if (current_slot) {
@@ -324,39 +315,18 @@ struct uwsgi_subscribe_node *uwsgi_add_subscribe_node(struct uwsgi_subscribe_slo
return NULL;
}
int has_address_and_vassal = 0;
if (usr->address_len > 0 && usr->vassal_len > 0)
has_address_and_vassal = 1;
node = current_slot->nodes;
while (node) {
if ((usr->address_len > 0 && !uwsgi_strncmp(node->name, node->len, usr->address, usr->address_len))
|| (usr->vassal_len > 0 && !uwsgi_strncmp(node->vassal, node->vassal_len, usr->vassal, usr->vassal_len))) {
if (!uwsgi_strncmp(node->name, node->len, usr->address, usr->address_len)) {
#ifdef UWSGI_SSL
// this should avoid sending sniffed packets...
if (current_slot->sign_ctx && !subscription_is_safe(usr) && usr->unix_check <= node->unix_check) {
uwsgi_log("[uwsgi-subscription for pid %d] invalid (sniffed ?) packet sent for slot: %.*s node: %.*s unix_check: %lu\n", (int) uwsgi.mypid, usr->keylen, usr->key, (int) usr->address_len, usr->address, (unsigned long) usr->unix_check);
uwsgi_log("[uwsgi-subscription for pid %d] invalid (sniffed ?) packet sent for slot: %.*s node: %.*s unix_check: %lu\n", (int) uwsgi.mypid, usr->keylen, usr->key, usr->address_len, usr->address, (unsigned long) usr->unix_check);
return NULL;
}
// eventually the packet could be upgraded to sni...
uwsgi_subscription_sni_check(current_slot, usr);
#endif
// only for vassal mode
if (has_address_and_vassal) {
if (usr->address_len == node->len && !memcmp(usr->address, node->name, node->len)) {
// record already exists, clear it ?
if (usr->clear) {
node->len = 0;
uwsgi_log("[uwsgi-subscription for pid %d] %.*s => cleared address for vassal node: %.*s (weight: %d, backup: %d)\n", (int) uwsgi.mypid, usr->keylen, usr->key, (int) usr->vassal_len, usr->vassal, usr->weight, usr->backup_level);
}
}
else {
memcpy(node->name, usr->address, usr->address_len);
node->len = usr->address_len;
uwsgi_log("[uwsgi-subscription for pid %d] %.*s => updated vassal node: %.*s with address %.*s (weight: %d, backup: %d)\n", (int) uwsgi.mypid, usr->keylen, usr->key, (int) usr->vassal_len, usr->vassal, (int) usr->address_len, usr->address, usr->weight, usr->backup_level);
}
}
// remove death mark and update cores and load
node->death_mark = 0;
node->last_check = uwsgi_now();
@@ -417,13 +387,7 @@ struct uwsgi_subscribe_node *uwsgi_add_subscribe_node(struct uwsgi_subscribe_slo
}
node->last_check = uwsgi_now();
node->slot = current_slot;
node->vassal_len = usr->vassal_len;
if (node->len > 0)
memcpy(node->name, usr->address, node->len);
if (usr->vassal_len > 0)
memcpy(node->vassal, usr->vassal, node->vassal_len);
memcpy(node->name, usr->address, usr->address_len);
if (old_node) {
old_node->next = node;
}
@@ -496,11 +460,7 @@ struct uwsgi_subscribe_node *uwsgi_add_subscribe_node(struct uwsgi_subscribe_slo
memcpy(current_slot->nodes->notify, usr->notify, usr->notify_len);
current_slot->nodes->notify[usr->notify_len] = 0;
}
if (usr->address_len > 0)
memcpy(current_slot->nodes->name, usr->address, usr->address_len);
current_slot->nodes->vassal_len = usr->vassal_len;
if (current_slot->nodes->vassal_len > 0)
memcpy(current_slot->nodes->vassal, usr->vassal, usr->vassal_len);
memcpy(current_slot->nodes->name, usr->address, usr->address_len);
current_slot->nodes->last_check = uwsgi_now();
current_slot->nodes->next = NULL;
@@ -522,17 +482,13 @@ struct uwsgi_subscribe_node *uwsgi_add_subscribe_node(struct uwsgi_subscribe_slo
current_slot->algo = usr->algo;
if (!current_slot->algo) current_slot->algo = uwsgi.subscription_algo;
if (!slot[hash_key] || current_slot->prev == NULL) {
slot[hash_key] = current_slot;
}
uwsgi_log("[uwsgi-subscription for pid %d] new pool: %.*s (hash key: %d, algo: %s)\n", (int) uwsgi.mypid, usr->keylen, usr->key, current_slot->hash, uwsgi_subscription_algo_name(current_slot->algo));
if (usr->address_len > 0) {
uwsgi_log("[uwsgi-subscription for pid %d] %.*s => new node: %.*s (weight: %d, backup: %d)\n", (int) uwsgi.mypid, usr->keylen, usr->key, usr->address_len, usr->address, usr->weight, usr->backup_level);
}
else {
uwsgi_log("[uwsgi-subscription for pid %d] %.*s => new vassal node: %.*s (weight: %d, backup: %d)\n", (int) uwsgi.mypid, usr->keylen, usr->key, usr->vassal_len, usr->vassal, usr->weight, usr->backup_level);
}
uwsgi_log("[uwsgi-subscription for pid %d] %.*s => new node: %.*s (weight: %d, backup: %d)\n", (int) uwsgi.mypid, usr->keylen, usr->key, usr->address_len, usr->address, usr->weight, usr->backup_level);
if (current_slot->nodes->notify[0]) {
char buf[1024];
@@ -975,8 +931,6 @@ void uwsgi_subscribe2(char *arg, uint8_t cmd) {
char *s2_proto = NULL;
char *s2_algo = NULL;
char *s2_backup = NULL;
char *s2_vassal = NULL;
char *s2_inactive = NULL;
struct uwsgi_buffer *ub = NULL;
if (uwsgi_kvlist_parse(arg, strlen(arg), ',', '=',
@@ -984,7 +938,6 @@ void uwsgi_subscribe2(char *arg, uint8_t cmd) {
"key", &s2_key,
"socket", &s2_socket,
"addr", &s2_addr,
"address", &s2_addr,
"weight", &s2_weight,
"modifier1", &s2_modifier1,
"modifier2", &s2_modifier2,
@@ -996,8 +949,6 @@ void uwsgi_subscribe2(char *arg, uint8_t cmd) {
"proto", &s2_proto,
"algo", &s2_algo,
"backup", &s2_backup,
"vassal", &s2_vassal,
"inactive", &s2_inactive,
NULL)) {
return;
}
@@ -1070,11 +1021,6 @@ void uwsgi_subscribe2(char *arg, uint8_t cmd) {
if (uwsgi_buffer_append_keynum(ub, "backup", 6, backup))
goto end;
if (s2_vassal) {
if (uwsgi_buffer_append_keyval(ub, "vassal", 6, s2_vassal, strlen(s2_vassal)))
goto end;
}
if (s2_sni_key) {
if (uwsgi_buffer_append_keyval(ub, "sni_key", 7, s2_sni_key, strlen(s2_sni_key)))
goto end;
@@ -1100,11 +1046,6 @@ void uwsgi_subscribe2(char *arg, uint8_t cmd) {
goto end;
}
if (s2_inactive) {
if (uwsgi_buffer_append_keyval(ub, "inactive", 8, s2_inactive, strlen(s2_inactive)))
goto end;
}
if (uwsgi.subscription_notify_socket) {
if (uwsgi_buffer_append_keyval(ub, "notify", 6, uwsgi.subscription_notify_socket, strlen(uwsgi.subscription_notify_socket)))
goto end;
@@ -1114,13 +1055,6 @@ void uwsgi_subscribe2(char *arg, uint8_t cmd) {
goto end;
}
// clear instead of unsubscribe
if (uwsgi_instance_is_dying && cmd == 1 && uwsgi.subscription_clear_on_shutdown) {
if (uwsgi_buffer_append_keynum(ub, "clear", 5, 1))
goto end;
cmd = 0;
}
if (uwsgi_subscription_ub_fix(ub, modifier1, modifier2, cmd, s2_sign)) goto end;
send_subscription(-1, s2_server, ub->buf, ub->pos);
@@ -1157,12 +1091,8 @@ end:
free(s2_proto);
if (s2_algo)
free(s2_algo);
if (s2_inactive)
free(s2_inactive);
if (s2_backup)
free(s2_backup);
if (s2_vassal)
free(s2_vassal);
}
void uwsgi_subscribe_all(uint8_t cmd, int verbose) {
+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
+45 -11
View File
@@ -218,9 +218,6 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"emperor-stats", required_argument, 0, "run the Emperor stats server", uwsgi_opt_set_str, &uwsgi.emperor_stats, 0},
{"emperor-stats-server", required_argument, 0, "run the Emperor stats server", uwsgi_opt_set_str, &uwsgi.emperor_stats, 0},
{"emperor-trigger-socket", required_argument, 0, "enable the Emperor trigger socket", uwsgi_opt_set_str, &uwsgi.emperor_trigger_socket, 0},
{"emperor-command-socket", required_argument, 0, "enable the Emperor command socket", uwsgi_opt_set_str, &uwsgi.emperor_command_socket, 0},
{"emperor-wait-for-command", no_argument, 0, "always wait for a 'spawn' Emperor command before starting a vassal", uwsgi_opt_true, &uwsgi.emperor_wait_for_command, 0},
{"emperor-wait-for-command-ignore", required_argument, 0, "ignore the emperor-wait-for-command directive for the specified vassal", uwsgi_opt_add_string_list, &uwsgi.emperor_wait_for_command_ignore, 0},
{"early-emperor", no_argument, 0, "spawn the emperor as soon as possibile", uwsgi_opt_true, &uwsgi.early_emperor, 0},
{"emperor-broodlord", required_argument, 0, "run the emperor in BroodLord mode", uwsgi_opt_set_int, &uwsgi.emperor_broodlord, 0},
{"emperor-throttle", required_argument, 0, "set throttling level (in milliseconds) for bad behaving vassals (default 1000)", uwsgi_opt_set_int, &uwsgi.emperor_throttle, 0},
@@ -329,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},
@@ -633,9 +631,8 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"notify-socket", required_argument, 0, "enable the notification socket", uwsgi_opt_set_str, &uwsgi.notify_socket, UWSGI_OPT_MASTER},
{"subscription-notify-socket", required_argument, 0, "set the notification socket for subscriptions", uwsgi_opt_set_str, &uwsgi.subscription_notify_socket, UWSGI_OPT_MASTER},
{"subscription-mountpoints", required_argument, 0, "enable mountpoints support for subscription system", uwsgi_opt_set_int, &uwsgi.subscription_mountpoints, UWSGI_OPT_MASTER},
{"subscription-mountpoint", required_argument, 0, "enable mountpoints support for subscription system", uwsgi_opt_set_int, &uwsgi.subscription_mountpoints, UWSGI_OPT_MASTER},
{"subscription-vassal-required", no_argument, 0, "require a vassal field for each subscription packet", uwsgi_opt_true, &uwsgi.subscription_vassal_required, UWSGI_OPT_MASTER},
{"subscription-mountpoints", no_argument, 0, "enable mountpoints support for subscription system", uwsgi_opt_true, &uwsgi.subscription_mountpoints, UWSGI_OPT_MASTER},
{"subscription-mountpoint", no_argument, 0, "enable mountpoints support for subscription system", uwsgi_opt_true, &uwsgi.subscription_mountpoints, UWSGI_OPT_MASTER},
#ifdef UWSGI_SSL
{"legion", required_argument, 0, "became a member of a legion", uwsgi_opt_legion, NULL, UWSGI_OPT_MASTER},
@@ -672,7 +669,6 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"subscription-tolerance", required_argument, 0, "set tolerance for subscription servers", uwsgi_opt_set_int, &uwsgi.subscription_tolerance, 0},
{"unsubscribe-on-graceful-reload", no_argument, 0, "force unsubscribe request even during graceful reload", uwsgi_opt_true, &uwsgi.unsubscribe_on_graceful_reload, 0},
{"start-unsubscribed", no_argument, 0, "configure subscriptions but do not send them (useful with master fifo)", uwsgi_opt_true, &uwsgi.subscriptions_blocked, 0},
{"subscription-clear-on-shutdown", no_argument, 0, "force clear instead of unsubscribe during shutdown", uwsgi_opt_true, &uwsgi.subscription_clear_on_shutdown, 0},
{"subscribe-with-modifier1", required_argument, 0, "force the specififed modifier1 when subscribing", uwsgi_opt_set_str, &uwsgi.subscribe_with_modifier1, UWSGI_OPT_MASTER},
@@ -718,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},
@@ -725,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
@@ -1694,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);
}
}
}
}
}
}
@@ -1837,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>
@@ -2085,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;
@@ -2358,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();
@@ -2440,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
@@ -2452,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
@@ -2664,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;
@@ -2687,6 +2714,8 @@ int uwsgi_start(void *v_argv) {
}
}
#endif
#endif
#ifndef __OpenBSD__
if (uwsgi.rl.rlim_max > 0) {
@@ -3861,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;
}
}
@@ -4157,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)
+4 -52
View File
@@ -316,30 +316,22 @@ void corerouter_manage_subscription(char *key, uint16_t keylen, char *val, uint1
usr->proto = val;
usr->proto_len = vallen;
}
else if (!uwsgi_strncmp("vassal", 6, key, keylen)) {
usr->vassal = val;
usr->vassal_len = vallen;
}
else if (!uwsgi_strncmp("clear", 5, key, keylen)) {
usr->clear = uwsgi_str_num(val, vallen);
}
}
void corerouter_close_peer(struct uwsgi_corerouter *ucr, struct corerouter_peer *peer) {
struct corerouter_session *cs = peer->session;
// manage subscription reference count
if (ucr->subscriptions && peer->un && peer->un->len > 0) {
// decrease reference count
#ifdef UWSGI_DEBUG
uwsgi_log("[1] node %.*s refcnt: %llu\n", peer->un->len, peer->un->name, peer->un->reference);
uwsgi_log("[1] node %.*s refcnt: %llu\n", peer->un->len, peer->un->name, peer->un->reference);
#endif
peer->un->reference--;
peer->un->reference--;
#ifdef UWSGI_DEBUG
uwsgi_log("[2] node %.*s refcnt: %llu\n", peer->un->len, peer->un->name, peer->un->reference);
uwsgi_log("[2] node %.*s refcnt: %llu\n", peer->un->len, peer->un->name, peer->un->reference);
#endif
}
if (peer->failed) {
@@ -486,24 +478,6 @@ static void corerouter_expire_timeouts(struct uwsgi_corerouter *ucr, time_t now)
if (urbt->value <= current) {
peer = (struct corerouter_peer *) urbt->data;
// you can manage deferred connections upto X retry times
if (peer->defer_connect) {
peer->defer_connect = 0;
peer->retries++;
// ignore return value
if (peer->un) {
if (peer->un->reference == 0) {
uwsgi_log("[BUG] subscription reference counting is 0 !!!\n");
corerouter_close_peer(ucr, peer);
continue;
}
peer->un->reference--;
}
peer->session->retry(peer);
// increase timeout;
urbt->value += peer->current_timeout;
continue;
}
peer->timed_out = 1;
if (peer->connecting) {
peer->failed = 1;
@@ -514,7 +488,6 @@ static void corerouter_expire_timeouts(struct uwsgi_corerouter *ucr, time_t now)
break;
}
}
int uwsgi_cr_set_hooks(struct corerouter_peer *peer, ssize_t (*read_hook)(struct corerouter_peer *), ssize_t (*write_hook)(struct corerouter_peer *)) {
@@ -707,9 +680,6 @@ void uwsgi_corerouter_loop(int id, void *data) {
if (!ucr->socket_timeout)
ucr->socket_timeout = 60;
if (!ucr->defer_connect_timeout)
ucr->defer_connect_timeout = 5;
if (!ucr->static_node_gracetime)
ucr->static_node_gracetime = 30;
@@ -738,23 +708,6 @@ void uwsgi_corerouter_loop(int id, void *data) {
uwsgi_log("*** %s stats server enabled on %s fd: %d ***\n", ucr->short_name, ucr->stats_server, ucr->cr_stats_server);
}
if (ucr->emperor_socket) {
char *colon = strchr(ucr->emperor_socket, ':');
if (colon) {
ucr->emperor_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
ucr->emperor_socket_addr_len = socket_to_in_addr(ucr->emperor_socket, colon, 0, &ucr->emperor_socket_addr.sa_in);
}
else {
ucr->emperor_socket_fd = socket(AF_UNIX, SOCK_DGRAM, 0);
ucr->emperor_socket_addr_len = socket_to_un_addr(ucr->emperor_socket, &ucr->emperor_socket_addr.sa_un);
}
if (ucr->emperor_socket_fd < 0) {
uwsgi_error("error creating emperor socket client: socket()");
exit(1);
}
uwsgi_log("emperor socket mapped to: %s\n", ucr->emperor_socket);
}
if (ucr->use_socket) {
ucr->to_socket = uwsgi_get_socket_by_num(ucr->socket_num);
@@ -1133,7 +1086,6 @@ void corerouter_send_stats(struct uwsgi_corerouter *ucr) {
if (uwsgi_stats_object_open(us)) goto end0;
if (uwsgi_stats_keyvaln_comma(us, "name", s_node->name, s_node->len)) goto end0;
if (uwsgi_stats_keyvaln_comma(us, "vassal", s_node->vassal, s_node->vassal_len)) goto end0;
if (uwsgi_stats_keylong_comma(us, "modifier1", (unsigned long long) s_node->modifier1)) goto end0;
if (uwsgi_stats_keylong_comma(us, "modifier2", (unsigned long long) s_node->modifier2)) goto end0;
-14
View File
@@ -199,11 +199,6 @@ struct corerouter_peer {
int is_buffering;
int buffering_fd;
int defer_connect;
char *vassal;
uint8_t vassal_len;
};
struct uwsgi_corerouter {
@@ -286,13 +281,6 @@ struct uwsgi_corerouter {
size_t buffer_size;
int fallback_on_no_key;
char *emperor_socket;
int emperor_socket_fd;
union uwsgi_sockaddr emperor_socket_addr;
socklen_t emperor_socket_addr_len;
int defer_connect_timeout;
};
// a session is started when a client connect to the router
@@ -376,5 +364,3 @@ struct corerouter_peer *uwsgi_cr_peer_add(struct corerouter_session *);
struct corerouter_peer *uwsgi_cr_peer_find_by_sid(struct corerouter_session *, uint32_t);
void corerouter_close_peer(struct uwsgi_corerouter *, struct corerouter_peer *);
struct uwsgi_rb_timer *corerouter_reset_timeout(struct uwsgi_corerouter *, struct corerouter_peer *);
int corerouter_spawn_vassal(struct uwsgi_corerouter *, struct uwsgi_subscribe_node *, int);
-25
View File
@@ -277,28 +277,3 @@ void uwsgi_corerouter_manage_internal_subscription(struct uwsgi_corerouter *ucr,
}
}
int corerouter_spawn_vassal(struct uwsgi_corerouter *ucr, struct uwsgi_subscribe_node *node, int attempt) {
// TODO
// a vassal field could be in the form address:name where address is the emperor command socket
// to use. As we cannot know in advance if it will be a UDP or UNIX address, we need to
// re-create and close the socket every time.
if (!ucr->emperor_socket)
return -1;
int ret = -1;
uwsgi_log_verbose("spawning vassal %.*s (attempt %d)\n", node->vassal_len, node->vassal, attempt);
struct uwsgi_buffer *ub = uwsgi_buffer_new(uwsgi.page_size);
// leave space for uwsgi header
ub->pos += 4;
if (uwsgi_buffer_append_keyval(ub, "cmd", 3, "spawn", 5)) goto end;
if (uwsgi_buffer_append_keyval(ub, "vassal", 6, node->vassal, node->vassal_len)) goto end;
// TODO choose modifier1 and 2
if (uwsgi_buffer_set_uh(ub, 0, 0)) goto end;
if (sendto(ucr->emperor_socket_fd, ub->buf, ub->pos, 0, &ucr->emperor_socket_addr.sa, ucr->emperor_socket_addr_len) < 0) {
uwsgi_error("corerouter_spawn_vassal()/sendto()");
}
ret = 0;
end:
uwsgi_buffer_destroy(ub);
return ret;
}
+3 -12
View File
@@ -54,21 +54,12 @@ int uwsgi_cr_map_use_subscription(struct uwsgi_corerouter *ucr, struct coreroute
usc.cookie = NULL;
peer->un = uwsgi_get_subscribe_node(ucr->subscriptions, peer->key, peer->key_len, &usc);
// check if the node is ready or it requires a vassal spawn
if (peer->un && (peer->un->len || peer->un->vassal_len)) {
if (peer->un && peer->un->len) {
peer->instance_address = peer->un->name;
peer->instance_address_len = peer->un->len;
peer->modifier1 = peer->un->modifier1;
peer->modifier2 = peer->un->modifier2;
peer->proto = peer->un->proto;
if (peer->un->len) {
peer->instance_address = peer->un->name;
peer->instance_address_len = peer->un->len;
}
else if (peer->un->vassal_len) {
peer->vassal = peer->un->vassal;
peer->vassal_len = peer->un->vassal_len;
corerouter_spawn_vassal(ucr, peer->un, peer->retries+1);
peer->defer_connect = 1;
}
}
else if (ucr->cheap && !ucr->i_am_cheap && uwsgi_no_subscriptions(ucr->subscriptions)) {
uwsgi_gateway_go_cheap(ucr->name, ucr->queue, &ucr->i_am_cheap);
+2 -71
View File
@@ -19,9 +19,6 @@ struct fastrouter_session {
int has_key;
uint64_t content_length;
uint64_t buffered;
char *path_info;
uint16_t path_info_len;
};
static struct uwsgi_option fastrouter_options[] = {
@@ -64,44 +61,9 @@ static struct uwsgi_option fastrouter_options[] = {
{"fastrouter-fallback-on-no-key", no_argument, 0, "move to fallback node even if a subscription key is not found", uwsgi_opt_true, &ufr.cr.fallback_on_no_key, 0},
{"fastrouter-force-key", required_argument, 0, "skip uwsgi parsing and directly set a key", uwsgi_opt_set_str, &ufr.force_key, 0},
{"fastrouter-emperor-socket", required_argument, 0, "set the emperor command socket that will receive spawn commands", uwsgi_opt_set_str, &ufr.cr.emperor_socket, 0},
{"fastrouter-defer-connect-timeout", required_argument, 0, "set fastrouter defer connect timeout", uwsgi_opt_set_int, &ufr.cr.defer_connect_timeout, 0},
{"fastrouter-max-retries", required_argument, 0, "set fastrouter max retry attempts", uwsgi_opt_set_int, &ufr.cr.max_retries, 0},
UWSGI_END_OF_OPTIONS
};
static int rebuild_key_for_mountpoint(char *path_info, uint16_t path_info_len, struct corerouter_peer *peer) {
if (path_info_len == 0) return -1;
if (path_info[0] != '/') return -1;
uint16_t len = path_info_len -1;
// is it / ?
if (len == 0) return 0;
// now find the second slash occurrence (if any)
char *second_slash = NULL;
char *last_slash = path_info;
int i;
for(i=0;i<uwsgi.subscription_mountpoints;i++) {
if (len < 1) break;
second_slash = memchr(last_slash+1, '/', len);
if (!second_slash) {
last_slash += 1+len;
break;
}
len -= second_slash - last_slash;
last_slash = second_slash;
}
char *new_key = uwsgi_concat2n(peer->key, peer->key_len, path_info, last_slash - path_info);
uint16_t new_key_len = peer->key_len + (last_slash - path_info);
if (new_key_len <= 0xff) {
memcpy(peer->key, new_key, new_key_len);
peer->key_len = new_key_len;
}
free(new_key);
return 0;
}
static void fr_get_hostname(char *key, uint16_t keylen, char *val, uint16_t vallen, void *data) {
struct corerouter_peer *peer = (struct corerouter_peer *) data;
@@ -147,14 +109,6 @@ static void fr_get_hostname(char *key, uint16_t keylen, char *val, uint16_t vall
return;
}
if (uwsgi.subscription_mountpoints) {
if (!uwsgi_strncmp("PATH_INFO", 9, key, keylen)) {
fr->path_info = val;
fr->path_info_len = vallen;
}
}
if (ufr.cr.post_buffering > 0) {
if (!uwsgi_strncmp("CONTENT_LENGTH", 14, key, keylen)) {
fr->content_length = uwsgi_str_num(val, vallen);
@@ -271,8 +225,8 @@ static ssize_t fr_instance_connected(struct corerouter_peer *peer) {
peer->can_retry = 0;
// fix modifiers
peer->session->main_peer->in->buf[0] = peer->modifier1;
peer->session->main_peer->in->buf[3] = peer->modifier2;
peer->in->buf[0] = peer->modifier1;
peer->in->buf[3] = peer->modifier2;
// prepare to write the uwsgi packet
peer->out = peer->session->main_peer->in;
@@ -282,7 +236,6 @@ static ssize_t fr_instance_connected(struct corerouter_peer *peer) {
return fr_instance_send_request(peer);
}
// called after receaving the uwsgi header (read vars)
static ssize_t fr_recv_uwsgi_vars(struct corerouter_peer *main_peer) {
struct fastrouter_session *fr = (struct fastrouter_session *) main_peer->session;
@@ -369,24 +322,12 @@ static ssize_t fr_recv_uwsgi_vars(struct corerouter_peer *main_peer) {
if (new_peer->key_len == 0)
return -1;
if (uwsgi.subscription_mountpoints) {
if (rebuild_key_for_mountpoint(fr->path_info, fr->path_info_len, new_peer)) return -1;
}
// find an instance using the key
if (ucr->mapper(ucr, new_peer))
return -1;
// check instance
if (new_peer->instance_address_len == 0) {
// check if the connection was deferred
if (new_peer->defer_connect) {
new_peer->current_timeout = ufr.cr.defer_connect_timeout;
new_peer->timeout = corerouter_reset_timeout(&ufr.cr, new_peer);
// stop reading from the client
if (uwsgi_cr_set_hooks(main_peer, NULL, NULL)) return -1;
return len;
}
if (ufr.cr.fallback_on_no_key) {
new_peer->failed = 1;
new_peer->can_retry = 1;
@@ -445,16 +386,6 @@ static int fr_retry(struct corerouter_peer *peer) {
}
if (peer->instance_address_len == 0) {
// first retry is consumed for the first attempt
if (peer->defer_connect && (peer->retries+1) < ufr.cr.max_retries) {
peer->current_timeout = ufr.cr.defer_connect_timeout;
peer->timeout = corerouter_reset_timeout(&ufr.cr, peer);
// stop reading from the client
if (uwsgi_cr_set_hooks(peer->session->main_peer, NULL, NULL)) return -1;
return 1;
}
// ensure deferred connect is disabled
peer->defer_connect = 0;
return -1;
}
+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']
+25 -35
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;
@@ -2809,12 +2808,12 @@ struct uwsgi_server {
char *emperor_trigger_socket;
int emperor_trigger_socket_fd;
char *emperor_command_socket;
int emperor_command_socket_fd;
int emperor_wait_for_command;
struct uwsgi_string_list *emperor_wait_for_command_ignore;
int subscription_vassal_required;
int subscription_clear_on_shutdown;
int spooler_signal_as_task;
int log_worker;
// number of args to consider part of binary_path
int binary_argc;
};
struct uwsgi_rpc {
@@ -3422,11 +3421,6 @@ struct uwsgi_subscribe_req {
uint16_t proto_len;
struct uwsgi_subscribe_node *(*algo) (struct uwsgi_subscribe_slot *, struct uwsgi_subscribe_node *, struct uwsgi_subscription_client *);
char *vassal;
uint16_t vassal_len;
uint8_t clear;
};
void uwsgi_nuclear_blast();
@@ -3708,9 +3702,6 @@ struct uwsgi_subscribe_node {
uint64_t backup_level;
//here the solution is a bit hacky, we take the first letter of the proto ('u','\0' -> uwsgi, 'h' -> http, 'f' -> fastcgi, 's' -> scgi)
char proto;
char vassal[0xff];
uint16_t vassal_len;
};
struct uwsgi_subscribe_slot {
@@ -3815,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 *);
@@ -4015,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 {
@@ -4215,9 +4207,6 @@ struct uwsgi_instance {
// uWSGI 2.1 (vassal's attributes)
struct uwsgi_dyn_dict *attrs;
// when 1 the instance must be manually activated
int suspended;
};
struct uwsgi_instance *emperor_get_by_fd(int);
@@ -4564,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);
+7 -3
View File
@@ -5,7 +5,7 @@ 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')