mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-10-04 16:08:31 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d580705e71 | ||
|
|
93b0f72b11 | ||
|
|
8906d5d0c4 | ||
|
|
d56f16c56f | ||
|
|
a3caf36515 | ||
|
|
b6ed470ee8 | ||
|
|
22425fe92a | ||
|
|
37bc47cb82 | ||
|
|
35701f6ac6 | ||
|
|
fb23d4a8ae | ||
|
|
30c667d34f | ||
|
|
d09fd561b6 | ||
|
|
ff05c16577 | ||
|
|
eefaa98cf3 | ||
|
|
9c4d563c72 | ||
|
|
ceda8a41e3 | ||
|
|
3021ba3f85 | ||
|
|
3be7312aa8 | ||
|
|
83d782051c | ||
|
|
70996049cc | ||
|
|
e219e209a0 | ||
|
|
eb728cfe23 | ||
|
|
7569544329 | ||
|
|
ee86bf593d | ||
|
|
27ea120325 | ||
|
|
dd21877dcb | ||
|
|
36ca76a231 | ||
|
|
0e339cf968 | ||
|
|
762200fdd6 | ||
|
|
688a464451 | ||
|
|
0dafe8aa5e | ||
|
|
5410cb4fe7 | ||
|
|
86f55a69cf | ||
|
|
6bd59ffe1c | ||
|
|
95a139f73d | ||
|
|
2e71d62704 | ||
|
|
8942e832e9 | ||
|
|
14b0a512e4 | ||
|
|
0c062bbc1a | ||
|
|
c63d94cb6e | ||
|
|
4da7564c3b | ||
|
|
d38edd839e | ||
|
|
cce041c7f0 | ||
|
|
ca68d6938a | ||
|
|
6d700e5a8b | ||
|
|
bad07a8520 | ||
|
|
363b88a7b7 | ||
|
|
932ed8ee29 | ||
|
|
7b8e12911a | ||
|
|
c95062856b | ||
|
|
6840b287d4 | ||
|
|
ae9104ed91 | ||
|
|
6c8d6ea15b | ||
|
|
755eb3956d | ||
|
|
225dc6f7a3 | ||
|
|
8509c41fd6 | ||
|
|
2ae9ac8b88 | ||
|
|
fed00ee5d6 |
@@ -30,3 +30,5 @@ Danila Shtan <danila@shtan.ru>
|
||||
Yu Zhao (getcwd)
|
||||
Mathieu Dupuy
|
||||
Adriano Di Luzio (adriano@unbit.it)
|
||||
Curtis Maloney
|
||||
Vladimir Didenko
|
||||
|
||||
@@ -1464,12 +1464,32 @@ static void uwsgi_emperor_spawn_vassal(struct uwsgi_instance *n_ui) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (uwsgi.emperor_wrapper_override) {
|
||||
char *orig_wrapper = vassal_argv[0];
|
||||
uwsgi_foreach(usl, uwsgi.emperor_wrapper_override) {
|
||||
vassal_argv[0] = usl->value;
|
||||
uwsgi_log("[emperor] trying to use %s as binary wrapper ...\n", usl->value);
|
||||
execvp(vassal_argv[0], vassal_argv);
|
||||
// not here if the binary is found
|
||||
}
|
||||
vassal_argv[0] = orig_wrapper;
|
||||
}
|
||||
|
||||
// start !!!
|
||||
if (execvp(vassal_argv[0], vassal_argv)) {
|
||||
uwsgi_error("execvp()");
|
||||
}
|
||||
uwsgi_log("[emperor] binary path: %s\n", vassal_argv[0]);
|
||||
uwsgi_log("[emperor] is the uwsgi binary in your system PATH ?\n");
|
||||
|
||||
// trying fallback
|
||||
uwsgi_foreach(usl, uwsgi.emperor_wrapper_fallback) {
|
||||
uwsgi_log("[emperor] trying to use %s as binary fallback ...\n", usl->value);
|
||||
vassal_argv[0] = usl->value;
|
||||
execvp(vassal_argv[0], vassal_argv);
|
||||
// not here if the binary is found
|
||||
}
|
||||
// never here
|
||||
exit(UWSGI_EXILE_CODE);
|
||||
}
|
||||
@@ -2275,6 +2295,9 @@ void uwsgi_check_emperor() {
|
||||
}
|
||||
free(env_emperor_fd_config);
|
||||
}
|
||||
if (fds)
|
||||
free(fds);
|
||||
close(proxy_fd);
|
||||
break;
|
||||
}
|
||||
next:
|
||||
|
||||
+1
-2
@@ -464,6 +464,7 @@ void uwsgi_exception_setup_handlers() {
|
||||
|
||||
struct uwsgi_string_list *usl = uwsgi.exception_handlers_instance;
|
||||
while(usl) {
|
||||
// do not free handler !!!
|
||||
char *handler = uwsgi_str(usl->value);
|
||||
char *colon = strchr(handler, ':');
|
||||
if (colon) {
|
||||
@@ -472,10 +473,8 @@ void uwsgi_exception_setup_handlers() {
|
||||
struct uwsgi_exception_handler *ueh = uwsgi_exception_handler_by_name(handler);
|
||||
if (!ueh) {
|
||||
uwsgi_log("unable to find exception handler: %s\n", handler);
|
||||
free(handler);
|
||||
exit(1);
|
||||
}
|
||||
free(handler);
|
||||
|
||||
struct uwsgi_exception_handler_instance *uehi = uwsgi_calloc(sizeof(struct uwsgi_exception_handler_instance));
|
||||
uehi->handler = ueh;
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ void gateway_respawn(int id) {
|
||||
|
||||
if (gw_pid == 0) {
|
||||
uwsgi_fixup_fds(0, 0, ug);
|
||||
uwsgi_close_all_sockets();
|
||||
uwsgi_close_all_unshared_sockets();
|
||||
if (uwsgi.master_as_root)
|
||||
uwsgi_as_root();
|
||||
#ifdef __linux__
|
||||
|
||||
@@ -91,6 +91,14 @@ static int uwsgi_hook_exec(char *arg) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int uwsgi_hook_safeexec(char *arg) {
|
||||
int ret = uwsgi_run_command_and_wait(NULL, arg);
|
||||
if (ret != 0) {
|
||||
uwsgi_log("command \"%s\" exited with non-zero code: %d\n", arg, ret);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uwsgi_hook_exit(char *arg) {
|
||||
int exit_code = 0;
|
||||
if (strlen(arg) > 1) {
|
||||
@@ -399,6 +407,24 @@ static int uwsgi_hook_hostname(char *arg) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static int uwsgi_hook_unix_signal(char *arg) {
|
||||
char *space = strchr(arg, ' ');
|
||||
if (!space) {
|
||||
uwsgi_log("invalid unix_signal syntax, must be <signum> <func>\n");
|
||||
return -1;
|
||||
}
|
||||
*space = 0;
|
||||
int signum = atoi(arg);
|
||||
*space = ' ';
|
||||
void (*func)(int) = dlsym(RTLD_DEFAULT, space+1);
|
||||
if (!func) {
|
||||
uwsgi_log("unable to find function \"%s\"\n", space+1);
|
||||
return -1;
|
||||
}
|
||||
uwsgi_unix_signal(signum, func);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int uwsgi_hook_callint(char *arg) {
|
||||
char *space = strchr(arg, ' ');
|
||||
@@ -549,6 +575,22 @@ static int uwsgi_hook_retryrpc(char *arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int uwsgi_hook_wait_for_fs(char *arg) {
|
||||
return uwsgi_wait_for_fs(arg, 0);
|
||||
}
|
||||
|
||||
static int uwsgi_hook_wait_for_file(char *arg) {
|
||||
return uwsgi_wait_for_fs(arg, 1);
|
||||
}
|
||||
|
||||
static int uwsgi_hook_wait_for_dir(char *arg) {
|
||||
return uwsgi_wait_for_fs(arg, 2);
|
||||
}
|
||||
|
||||
static int uwsgi_hook_wait_for_socket(char *arg) {
|
||||
return uwsgi_wait_for_socket(arg);
|
||||
}
|
||||
|
||||
void uwsgi_register_base_hooks() {
|
||||
uwsgi_register_hook("cd", uwsgi_hook_chdir);
|
||||
uwsgi_register_hook("chdir", uwsgi_hook_chdir);
|
||||
@@ -562,6 +604,7 @@ void uwsgi_register_base_hooks() {
|
||||
uwsgi_register_hook("sticky", uwsgi_hook_sticky);
|
||||
|
||||
uwsgi_register_hook("exec", uwsgi_hook_exec);
|
||||
uwsgi_register_hook("safeexec", uwsgi_hook_safeexec);
|
||||
|
||||
uwsgi_register_hook("create", uwsgi_hook_creat);
|
||||
uwsgi_register_hook("creat", uwsgi_hook_creat);
|
||||
@@ -589,6 +632,14 @@ void uwsgi_register_base_hooks() {
|
||||
uwsgi_register_hook("rpc", uwsgi_hook_rpc);
|
||||
uwsgi_register_hook("retryrpc", uwsgi_hook_retryrpc);
|
||||
|
||||
uwsgi_register_hook("wait_for_fs", uwsgi_hook_wait_for_fs);
|
||||
uwsgi_register_hook("wait_for_file", uwsgi_hook_wait_for_file);
|
||||
uwsgi_register_hook("wait_for_dir", uwsgi_hook_wait_for_dir);
|
||||
|
||||
uwsgi_register_hook("wait_for_socket", uwsgi_hook_wait_for_socket);
|
||||
|
||||
uwsgi_register_hook("unix_signal", uwsgi_hook_unix_signal);
|
||||
|
||||
// for testing
|
||||
uwsgi_register_hook("exit", uwsgi_hook_exit);
|
||||
uwsgi_register_hook("print", uwsgi_hook_print);
|
||||
|
||||
@@ -471,6 +471,10 @@ void sanitize_args() {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (uwsgi.evil_reload_on_rss || uwsgi.evil_reload_on_as) {
|
||||
if (!uwsgi.mem_collector_freq) uwsgi.mem_collector_freq = 3;
|
||||
}
|
||||
|
||||
/* here we try to choose if thunder lock is a good thing */
|
||||
#ifdef UNBIT
|
||||
if (uwsgi.numproc > 1 && !uwsgi.map_socket) {
|
||||
|
||||
+6
-8
@@ -277,14 +277,12 @@ static void legions_check_nodes_step2() {
|
||||
memcpy(best_uuid, node->uuid, 36);
|
||||
}
|
||||
// go on if i am not an arbiter
|
||||
else if (ul->valor > 0) {
|
||||
// no potential Lord is available, i will propose myself
|
||||
// but only if i am not suspended...
|
||||
if (uwsgi_now() > ul->suspended_til) {
|
||||
best_valor = ul->valor;
|
||||
memcpy(best_uuid, ul->uuid, 36);
|
||||
i_am_the_best = 1;
|
||||
}
|
||||
// no potential Lord is available, i will propose myself
|
||||
// but only if i am not suspended...
|
||||
else if (ul->valor > 0 && uwsgi_now() > ul->suspended_til) {
|
||||
best_valor = ul->valor;
|
||||
memcpy(best_uuid, ul->uuid, 36);
|
||||
i_am_the_best = 1;
|
||||
}
|
||||
else {
|
||||
// empty lord
|
||||
|
||||
+2
-4
@@ -3,6 +3,7 @@
|
||||
#endif
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
|
||||
#include <sys/user.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <kvm.h>
|
||||
#elif defined(__sun__)
|
||||
/* Terrible Hack !!! */
|
||||
@@ -13,10 +14,6 @@
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __DragonFly__
|
||||
#include <uwsgi.h>
|
||||
#endif
|
||||
@@ -1514,6 +1511,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++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+9
-8
@@ -258,17 +258,18 @@ static void master_check_listen_queue() {
|
||||
if (uwsgi_sock->queue > backlog) {
|
||||
backlog = uwsgi_sock->queue;
|
||||
}
|
||||
|
||||
if (uwsgi_sock->queue > 0 && uwsgi_sock->queue >= uwsgi_sock->max_queue) {
|
||||
uwsgi_log_verbose("*** uWSGI listen queue of socket \"%s\" (fd: %d) full !!! (%llu/%llu) ***\n", uwsgi_sock->name, uwsgi_sock->fd, (unsigned long long) uwsgi_sock->queue, (unsigned long long) uwsgi_sock->max_queue);
|
||||
}
|
||||
|
||||
if (uwsgi.alarm_backlog) {
|
||||
char buf[1024];
|
||||
int ret = snprintf(buf, 1024, "listen queue of socket \"%s\" (fd: %d) full !!! (%llu/%llu)", uwsgi_sock->name, uwsgi_sock->fd, (unsigned long long) uwsgi_sock->queue, (unsigned long long) uwsgi_sock->max_queue);
|
||||
if (ret > 0 && ret < 1024) {
|
||||
struct uwsgi_string_list *usl = NULL;
|
||||
uwsgi_foreach(usl, uwsgi.alarm_backlog) {
|
||||
uwsgi_alarm_trigger(usl->value, buf, ret);
|
||||
if (uwsgi.alarm_backlog) {
|
||||
char buf[1024];
|
||||
int ret = snprintf(buf, 1024, "listen queue of socket \"%s\" (fd: %d) full !!! (%llu/%llu)", uwsgi_sock->name, uwsgi_sock->fd, (unsigned long long) uwsgi_sock->queue, (unsigned long long) uwsgi_sock->max_queue);
|
||||
if (ret > 0 && ret < 1024) {
|
||||
struct uwsgi_string_list *usl = NULL;
|
||||
uwsgi_foreach(usl, uwsgi.alarm_backlog) {
|
||||
uwsgi_alarm_trigger(usl->value, buf, ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ int uwsgi_master_check_reload(char **argv) {
|
||||
|
||||
// check for chain reload
|
||||
void uwsgi_master_check_chain() {
|
||||
static time_t last_check = 0;
|
||||
|
||||
if (!uwsgi.status.chain_reloading) return;
|
||||
|
||||
// we need to ensure the previous worker (if alive) is accepting new requests
|
||||
@@ -49,7 +51,11 @@ void uwsgi_master_check_chain() {
|
||||
if (previous_worker->pid > 0 && !previous_worker->cheaped) {
|
||||
// the worker has been respawned but it is still not ready
|
||||
if (previous_worker->accepting == 0) {
|
||||
uwsgi_log_verbose("chain is still waiting for worker %d...\n", uwsgi.status.chain_reloading-1);
|
||||
time_t now = uwsgi_now();
|
||||
if (now != last_check) {
|
||||
uwsgi_log_verbose("chain is still waiting for worker %d...\n", uwsgi.status.chain_reloading-1);
|
||||
last_check = now;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -704,6 +704,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);
|
||||
|
||||
@@ -756,6 +756,27 @@ static int uwsgi_router_fixcl(struct uwsgi_route *ur, char *arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// force content length
|
||||
static int transform_forcecl(struct wsgi_request *wsgi_req, struct uwsgi_transformation *ut) {
|
||||
char buf[sizeof(UMAX64_STR)+1];
|
||||
int ret = snprintf(buf, sizeof(UMAX64_STR)+1, "%llu", (unsigned long long) ut->chunk->pos);
|
||||
if (ret <= 0 || ret >= (int) (sizeof(UMAX64_STR)+1)) {
|
||||
wsgi_req->write_errors++;
|
||||
return -1;
|
||||
}
|
||||
// do not check for errors !!!
|
||||
uwsgi_response_add_header_force(wsgi_req, "Content-Length", 14, buf, ret);
|
||||
return 0;
|
||||
}
|
||||
static int uwsgi_router_forcecl_func(struct wsgi_request *wsgi_req, struct uwsgi_route *route) {
|
||||
uwsgi_add_transformation(wsgi_req, transform_forcecl, NULL);
|
||||
return UWSGI_ROUTE_NEXT;
|
||||
}
|
||||
static int uwsgi_router_forcecl(struct uwsgi_route *ur, char *arg) {
|
||||
ur->func = uwsgi_router_forcecl_func;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// log route
|
||||
static int uwsgi_router_log_func(struct wsgi_request *wsgi_req, struct uwsgi_route *ur) {
|
||||
|
||||
@@ -1194,6 +1215,27 @@ static int uwsgi_router_setpathinfo(struct uwsgi_route *ur, char *arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// fixpathinfo route
|
||||
static int uwsgi_router_fixpathinfo_func(struct wsgi_request *wsgi_req, struct uwsgi_route *ur) {
|
||||
if (wsgi_req->script_name_len == 0)
|
||||
return UWSGI_ROUTE_NEXT;
|
||||
|
||||
char *ptr = uwsgi_req_append(wsgi_req, "PATH_INFO", 9, wsgi_req->path_info+wsgi_req->script_name_len, wsgi_req->path_info_len - wsgi_req->script_name_len);
|
||||
if (!ptr) {
|
||||
return UWSGI_ROUTE_BREAK;
|
||||
}
|
||||
wsgi_req->path_info = wsgi_req->path_info+wsgi_req->script_name_len;
|
||||
wsgi_req->path_info_len = wsgi_req->path_info_len - wsgi_req->script_name_len;
|
||||
return UWSGI_ROUTE_NEXT;
|
||||
}
|
||||
static int uwsgi_router_fixpathinfo(struct uwsgi_route *ur, char *arg) {
|
||||
ur->func = uwsgi_router_fixpathinfo_func;
|
||||
ur->data = arg;
|
||||
ur->data_len = strlen(arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// setscheme route
|
||||
static int uwsgi_router_setscheme_func(struct wsgi_request *wsgi_req, struct uwsgi_route *ur) {
|
||||
char **subject = (char **) (((char *)(wsgi_req))+ur->subject);
|
||||
@@ -1757,6 +1799,10 @@ static char *uwsgi_route_var_uwsgi(struct wsgi_request *wsgi_req, char *key, uin
|
||||
ret = uwsgi_64bit2str(wsgi_req->response_size);
|
||||
*vallen = strlen(ret);
|
||||
}
|
||||
else if (!uwsgi_strncmp(key, keylen, "sor", 3)) {
|
||||
ret = uwsgi_64bit2str(wsgi_req->start_of_request);
|
||||
*vallen = strlen(ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1793,6 +1839,10 @@ static char *uwsgi_route_var_time(struct wsgi_request *wsgi_req, char *key, uint
|
||||
ret = uwsgi_num2str(uwsgi_now());
|
||||
*vallen = strlen(ret);
|
||||
}
|
||||
else if (!uwsgi_strncmp(key, keylen, "micros", 6)) {
|
||||
ret = uwsgi_64bit2str(uwsgi_micros());
|
||||
*vallen = strlen(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1850,6 +1900,7 @@ void uwsgi_register_embedded_routers() {
|
||||
uwsgi_register_router("seturi", uwsgi_router_seturi);
|
||||
uwsgi_register_router("setremoteaddr", uwsgi_router_setremoteaddr);
|
||||
uwsgi_register_router("setpathinfo", uwsgi_router_setpathinfo);
|
||||
uwsgi_register_router("fixpathinfo", uwsgi_router_fixpathinfo);
|
||||
uwsgi_register_router("setdocroot", uwsgi_router_setdocroot);
|
||||
uwsgi_register_router("setscheme", uwsgi_router_setscheme);
|
||||
uwsgi_register_router("setprocname", uwsgi_router_setprocname);
|
||||
@@ -1865,6 +1916,7 @@ void uwsgi_register_embedded_routers() {
|
||||
|
||||
uwsgi_register_router("flush", uwsgi_router_flush);
|
||||
uwsgi_register_router("fixcl", uwsgi_router_fixcl);
|
||||
uwsgi_register_router("forcecl", uwsgi_router_forcecl);
|
||||
|
||||
uwsgi_register_router("harakiri", uwsgi_router_harakiri);
|
||||
|
||||
|
||||
+9
-9
@@ -280,8 +280,8 @@ struct uwsgi_sharedarea *uwsgi_sharedarea_init_fd(int fd, uint64_t len, off_t of
|
||||
}
|
||||
uwsgi.sharedareas[id]->id = id;
|
||||
uwsgi.sharedareas[id]->fd = fd;
|
||||
uwsgi.sharedareas[id]->pages = len / uwsgi.page_size;
|
||||
if (len % uwsgi.page_size != 0) uwsgi.sharedareas[id]->pages++;
|
||||
uwsgi.sharedareas[id]->pages = len / (size_t) uwsgi.page_size;
|
||||
if (len % (size_t) uwsgi.page_size != 0) uwsgi.sharedareas[id]->pages++;
|
||||
uwsgi.sharedareas[id]->max_pos = len-1;
|
||||
char *id_str = uwsgi_num2str(id);
|
||||
uwsgi.sharedareas[id]->lock = uwsgi_rwlock_init(uwsgi_concat2("sharedarea", id_str));
|
||||
@@ -292,12 +292,12 @@ struct uwsgi_sharedarea *uwsgi_sharedarea_init_fd(int fd, uint64_t len, off_t of
|
||||
|
||||
struct uwsgi_sharedarea *uwsgi_sharedarea_init(int pages) {
|
||||
int id = uwsgi_sharedarea_new_id();
|
||||
uwsgi.sharedareas[id] = uwsgi_calloc_shared(uwsgi.page_size * (pages + 1));
|
||||
uwsgi.sharedareas[id]->area = ((char *) uwsgi.sharedareas[id]) + uwsgi.page_size;
|
||||
uwsgi.sharedareas[id] = uwsgi_calloc_shared((size_t)uwsgi.page_size * (size_t)(pages + 1));
|
||||
uwsgi.sharedareas[id]->area = ((char *) uwsgi.sharedareas[id]) + (size_t) uwsgi.page_size;
|
||||
uwsgi.sharedareas[id]->id = id;
|
||||
uwsgi.sharedareas[id]->fd = -1;
|
||||
uwsgi.sharedareas[id]->pages = pages;
|
||||
uwsgi.sharedareas[id]->max_pos = (uwsgi.page_size * pages) -1;
|
||||
uwsgi.sharedareas[id]->max_pos = ((size_t)uwsgi.page_size * (size_t)pages) -1;
|
||||
char *id_str = uwsgi_num2str(id);
|
||||
uwsgi.sharedareas[id]->lock = uwsgi_rwlock_init(uwsgi_concat2("sharedarea", id_str));
|
||||
free(id_str);
|
||||
@@ -310,8 +310,8 @@ struct uwsgi_sharedarea *uwsgi_sharedarea_init_ptr(char *area, uint64_t len) {
|
||||
uwsgi.sharedareas[id]->area = area;
|
||||
uwsgi.sharedareas[id]->id = id;
|
||||
uwsgi.sharedareas[id]->fd = -1;
|
||||
uwsgi.sharedareas[id]->pages = len / uwsgi.page_size;
|
||||
if (len % uwsgi.page_size != 0) uwsgi.sharedareas[id]->pages++;
|
||||
uwsgi.sharedareas[id]->pages = len / (size_t) uwsgi.page_size;
|
||||
if (len % (size_t) uwsgi.page_size != 0) uwsgi.sharedareas[id]->pages++;
|
||||
uwsgi.sharedareas[id]->max_pos = len-1;
|
||||
char *id_str = uwsgi_num2str(id);
|
||||
uwsgi.sharedareas[id]->lock = uwsgi_rwlock_init(uwsgi_concat2("sharedarea", id_str));
|
||||
@@ -348,8 +348,8 @@ struct uwsgi_sharedarea *uwsgi_sharedarea_init_keyval(char *arg) {
|
||||
else {
|
||||
len = uwsgi_n64(s_size);
|
||||
}
|
||||
pages = len / uwsgi.page_size;
|
||||
if (len % uwsgi.page_size != 0) pages++;
|
||||
pages = len / (size_t) uwsgi.page_size;
|
||||
if (len % (size_t) uwsgi.page_size != 0) pages++;
|
||||
}
|
||||
|
||||
if (s_offset) {
|
||||
|
||||
+16
-1
@@ -710,6 +710,11 @@ int bind_to_tcp(char *socket_name, int listen_queue, char *tcp_port) {
|
||||
|
||||
if (uwsgi.tcp_fast_open) {
|
||||
#ifdef TCP_FASTOPEN
|
||||
|
||||
#ifndef SOL_TCP
|
||||
#define SOL_TCP IPPROTO_TCP
|
||||
#endif
|
||||
|
||||
if (setsockopt(serverfd, SOL_TCP, TCP_FASTOPEN, (const void *) &uwsgi.tcp_fast_open, sizeof(int)) < 0) {
|
||||
uwsgi_error("TCP_FASTOPEN setsockopt()");
|
||||
}
|
||||
@@ -1249,10 +1254,20 @@ void uwsgi_add_socket_from_fd(struct uwsgi_socket *uwsgi_sock, int fd) {
|
||||
}
|
||||
|
||||
void uwsgi_close_all_sockets() {
|
||||
struct uwsgi_socket *uwsgi_sock = uwsgi.sockets;
|
||||
|
||||
while (uwsgi_sock) {
|
||||
if (uwsgi_sock->bound)
|
||||
close(uwsgi_sock->fd);
|
||||
uwsgi_sock = uwsgi_sock->next;
|
||||
}
|
||||
}
|
||||
|
||||
void uwsgi_close_all_unshared_sockets() {
|
||||
struct uwsgi_socket *uwsgi_sock = uwsgi.sockets;
|
||||
|
||||
while (uwsgi_sock) {
|
||||
if (uwsgi_sock->bound)
|
||||
if (uwsgi_sock->bound && !uwsgi_sock->shared)
|
||||
close(uwsgi_sock->fd);
|
||||
uwsgi_sock = uwsgi_sock->next;
|
||||
}
|
||||
|
||||
+1
-1
@@ -480,7 +480,7 @@ static void spooler_scandir(struct uwsgi_spooler *uspool, char *dir) {
|
||||
if (!dir)
|
||||
dir = uspool->dir;
|
||||
|
||||
n = scandir(dir, &tasklist, 0, versionsort);
|
||||
n = scandir(dir, &tasklist, NULL, versionsort);
|
||||
if (n < 0) {
|
||||
uwsgi_error("scandir()");
|
||||
return;
|
||||
|
||||
+12
-1
@@ -30,7 +30,18 @@ void uwsgi_ssl_info_cb(SSL const *ssl, int where, int ret) {
|
||||
}
|
||||
|
||||
int uwsgi_ssl_verify_callback(int ok, X509_STORE_CTX * x509_store) {
|
||||
return 1;
|
||||
if (!ok && uwsgi.ssl_verbose) {
|
||||
char buf[256];
|
||||
X509 *err_cert;
|
||||
int depth;
|
||||
int err;
|
||||
depth = X509_STORE_CTX_get_error_depth(x509_store);
|
||||
err_cert = X509_STORE_CTX_get_current_cert(x509_store);
|
||||
X509_NAME_oneline(X509_get_subject_name(err_cert), buf, 256);
|
||||
err = X509_STORE_CTX_get_error(x509_store);
|
||||
uwsgi_log("[uwsgi-ssl] client certificate verify error: num=%d:%s:depth=%d:%s\n", err, X509_verify_cert_error_string(err), depth, buf);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
int uwsgi_ssl_session_new_cb(SSL *ssl, SSL_SESSION *sess) {
|
||||
|
||||
+12
-13
@@ -463,23 +463,22 @@ int uwsgi_real_file_serve(struct wsgi_request *wsgi_req, char *real_filename, si
|
||||
wsgi_req->do_not_account_avg_rt = 1;
|
||||
|
||||
size_t fsize = st->st_size;
|
||||
if (wsgi_req->range_to) {
|
||||
fsize = wsgi_req->range_to - wsgi_req->range_from;
|
||||
if (fsize > (size_t)st->st_size) {
|
||||
fsize = st->st_size;
|
||||
}
|
||||
// security check
|
||||
if (wsgi_req->range_from > fsize) {
|
||||
wsgi_req->range_from = 0;
|
||||
wsgi_req->range_to = 0;
|
||||
}
|
||||
else {
|
||||
// reset in case of inconsistent size
|
||||
if (wsgi_req->range_from > fsize) {
|
||||
wsgi_req->range_from = 0;
|
||||
fsize = 0;
|
||||
}
|
||||
else {
|
||||
fsize -= wsgi_req->range_from;
|
||||
}
|
||||
fsize -= wsgi_req->range_from;
|
||||
}
|
||||
|
||||
if (wsgi_req->range_to) {
|
||||
fsize = (wsgi_req->range_to - wsgi_req->range_from)+1;
|
||||
if (fsize + wsgi_req->range_from > (size_t) (st->st_size)) {
|
||||
fsize = st->st_size - wsgi_req->range_from;
|
||||
}
|
||||
}
|
||||
|
||||
// HTTP status
|
||||
if (fsize > 0 && (wsgi_req->range_from || wsgi_req->range_to)) {
|
||||
if (uwsgi_response_prepare_headers(wsgi_req, "206 Partial Content", 19)) return -1;
|
||||
|
||||
+28
-1
@@ -3514,7 +3514,7 @@ int uwsgi_tmpfd() {
|
||||
tmpdir = "/tmp";
|
||||
}
|
||||
#ifdef O_TMPFILE
|
||||
fd = open(tmpdir, O_TMPFILE | O_RDWR);
|
||||
fd = open(tmpdir, O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR);
|
||||
if (fd >= 0) {
|
||||
return fd;
|
||||
}
|
||||
@@ -4446,6 +4446,7 @@ void uwsgi_setns(char *path) {
|
||||
}
|
||||
}
|
||||
free(fds);
|
||||
close(ns_fd);
|
||||
break;
|
||||
}
|
||||
if (fds)
|
||||
@@ -4510,6 +4511,7 @@ retry:
|
||||
sleep(1);
|
||||
counter++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// type -> 1 file, 2 dir, 0 both
|
||||
@@ -4534,4 +4536,29 @@ retry:
|
||||
sleep(1);
|
||||
counter++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int uwsgi_wait_for_socket(char *socket_name) {
|
||||
if (!uwsgi.wait_for_socket_timeout) {
|
||||
uwsgi.wait_for_socket_timeout = 60;
|
||||
}
|
||||
uwsgi_log("waiting for %s (max %d seconds) ...\n", socket_name, uwsgi.wait_for_socket_timeout);
|
||||
int counter = 0;
|
||||
for (;;) {
|
||||
if (counter > uwsgi.wait_for_socket_timeout) {
|
||||
uwsgi_log("%s unavailable after %d seconds\n", socket_name, counter);
|
||||
return -1;
|
||||
}
|
||||
// wait for 1 second to respect uwsgi.wait_for_fs_timeout
|
||||
int fd = uwsgi_connect(socket_name, 1, 0);
|
||||
if (fd < 0) goto retry;
|
||||
close(fd);
|
||||
uwsgi_log_verbose("%s ready\n", socket_name);
|
||||
return 0;
|
||||
retry:
|
||||
sleep(1);
|
||||
counter++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
+64
-7
@@ -2,7 +2,7 @@
|
||||
|
||||
*** uWSGI ***
|
||||
|
||||
Copyright (C) 2009-2014 Unbit S.a.s. <info@unbit.it>
|
||||
Copyright (C) 2009-2015 Unbit S.a.s. <info@unbit.it>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
@@ -202,6 +202,8 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
{"emperor", required_argument, 0, "run the Emperor", uwsgi_opt_add_string_list, &uwsgi.emperor, 0},
|
||||
{"emperor-proxy-socket", required_argument, 0, "force the vassal to became an Emperor proxy", uwsgi_opt_set_str, &uwsgi.emperor_proxy, 0},
|
||||
{"emperor-wrapper", required_argument, 0, "set a binary wrapper for vassals", uwsgi_opt_set_str, &uwsgi.emperor_wrapper, 0},
|
||||
{"emperor-wrapper-override", required_argument, 0, "set a binary wrapper for vassals to try before the default one", uwsgi_opt_add_string_list, &uwsgi.emperor_wrapper_override, 0},
|
||||
{"emperor-wrapper-fallback", required_argument, 0, "set a binary wrapper for vassals to try as a last resort", uwsgi_opt_add_string_list, &uwsgi.emperor_wrapper_fallback, 0},
|
||||
{"emperor-nofollow", no_argument, 0, "do not follow symlinks when checking for mtime", uwsgi_opt_true, &uwsgi.emperor_nofollow, 0},
|
||||
{"emperor-procname", required_argument, 0, "set the Emperor process name", uwsgi_opt_set_str, &uwsgi.emperor_procname, 0},
|
||||
{"emperor-freq", required_argument, 0, "set the Emperor scan frequency (default 3 seconds)", uwsgi_opt_set_int, &uwsgi.emperor_freq, 0},
|
||||
@@ -467,6 +469,9 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
{"wait-for-mountpoint", required_argument, 0, "wait for the specified mountpoint to appear before running root hooks", uwsgi_opt_add_string_list, &uwsgi.wait_for_mountpoint, 0},
|
||||
{"wait-for-fs-timeout", required_argument, 0, "set the timeout for wait-for-fs/file/dir", uwsgi_opt_set_int, &uwsgi.wait_for_fs_timeout, 0},
|
||||
|
||||
{"wait-for-socket", required_argument, 0, "wait for the specified socket to be ready before loading apps", uwsgi_opt_add_string_list, &uwsgi.wait_for_socket, 0},
|
||||
{"wait-for-socket-timeout", required_argument, 0, "set the timeout for wait-for-socket", uwsgi_opt_set_int, &uwsgi.wait_for_socket_timeout, 0},
|
||||
|
||||
{"call-asap", required_argument, 0, "call the specified function as soon as possible", uwsgi_opt_add_string_list, &uwsgi.call_asap, 0},
|
||||
{"call-pre-jail", required_argument, 0, "call the specified function before jailing", uwsgi_opt_add_string_list, &uwsgi.call_pre_jail, 0},
|
||||
{"call-post-jail", required_argument, 0, "call the specified function after jailing", uwsgi_opt_add_string_list, &uwsgi.call_post_jail, 0},
|
||||
@@ -516,6 +521,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
{"reload-on-rss", required_argument, 0, "reload if rss memory is higher than specified megabytes", uwsgi_opt_set_megabytes, &uwsgi.reload_on_rss, UWSGI_OPT_MEMORY},
|
||||
{"evil-reload-on-as", required_argument, 0, "force the master to reload a worker if its address space is higher than specified megabytes", uwsgi_opt_set_megabytes, &uwsgi.evil_reload_on_as, UWSGI_OPT_MASTER | UWSGI_OPT_MEMORY},
|
||||
{"evil-reload-on-rss", required_argument, 0, "force the master to reload a worker if its rss memory is higher than specified megabytes", uwsgi_opt_set_megabytes, &uwsgi.evil_reload_on_rss, UWSGI_OPT_MASTER | UWSGI_OPT_MEMORY},
|
||||
{"mem-collector-freq", required_argument, 0, "set the memory collector frequency when evil reloads are in place", uwsgi_opt_set_int, &uwsgi.mem_collector_freq, 0},
|
||||
|
||||
{"reload-on-fd", required_argument, 0, "reload if the specified file descriptor is ready", uwsgi_opt_add_string_list, &uwsgi.reload_on_fd, UWSGI_OPT_MASTER},
|
||||
{"brutal-reload-on-fd", required_argument, 0, "brutal reload if the specified file descriptor is ready", uwsgi_opt_add_string_list, &uwsgi.brutal_reload_on_fd, UWSGI_OPT_MASTER},
|
||||
@@ -696,7 +702,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
|
||||
{"alarm", required_argument, 0, "create a new alarm, syntax: <alarm> <plugin:args>", uwsgi_opt_add_string_list, &uwsgi.alarm_list, UWSGI_OPT_MASTER},
|
||||
{"alarm-cheap", required_argument, 0, "use main alarm thread rather than create dedicated threads for curl-based alarms", uwsgi_opt_true, &uwsgi.alarm_cheap, 0},
|
||||
{"alarm-freq", required_argument, 0, "tune the anti-loop alam system (default 3 seconds)", uwsgi_opt_set_int, &uwsgi.alarm_freq, 0},
|
||||
{"alarm-freq", required_argument, 0, "tune the anti-loop alarm system (default 3 seconds)", uwsgi_opt_set_int, &uwsgi.alarm_freq, 0},
|
||||
{"alarm-fd", required_argument, 0, "raise the specified alarm when an fd is read for read (by default it reads 1 byte, set 8 for eventfd)", uwsgi_opt_add_string_list, &uwsgi.alarm_fd_list, UWSGI_OPT_MASTER},
|
||||
{"alarm-segfault", required_argument, 0, "raise the specified alarm when the segmentation fault handler is executed", uwsgi_opt_add_string_list, &uwsgi.alarm_segfault, UWSGI_OPT_MASTER},
|
||||
{"segfault-alarm", required_argument, 0, "raise the specified alarm when the segmentation fault handler is executed", uwsgi_opt_add_string_list, &uwsgi.alarm_segfault, UWSGI_OPT_MASTER},
|
||||
@@ -1174,7 +1180,7 @@ void wait_for_threads() {
|
||||
int sudden_death = 0;
|
||||
|
||||
pthread_mutex_lock(&uwsgi.six_feet_under_lock);
|
||||
for (i = 0; i < uwsgi.threads; i++) {
|
||||
for (i = 1; i < uwsgi.threads; i++) {
|
||||
if (!pthread_equal(uwsgi.workers[uwsgi.mywid].cores[i].thread_id, pthread_self())) {
|
||||
if (pthread_cancel(uwsgi.workers[uwsgi.mywid].cores[i].thread_id)) {
|
||||
uwsgi_error("pthread_cancel()\n");
|
||||
@@ -1187,7 +1193,7 @@ void wait_for_threads() {
|
||||
goto end;
|
||||
|
||||
// wait for thread termination
|
||||
for (i = 0; i < uwsgi.threads; i++) {
|
||||
for (i = 1; i < uwsgi.threads; i++) {
|
||||
if (!pthread_equal(uwsgi.workers[uwsgi.mywid].cores[i].thread_id, pthread_self())) {
|
||||
ret = pthread_join(uwsgi.workers[uwsgi.mywid].cores[i].thread_id, NULL);
|
||||
if (ret) {
|
||||
@@ -1196,6 +1202,22 @@ void wait_for_threads() {
|
||||
}
|
||||
}
|
||||
|
||||
// cancel inital thread last since after pthread_cancel() and
|
||||
// pthread_join() is called on it, the whole process will appear to be
|
||||
// a zombie. although it won't eliminate process zombie time, but it
|
||||
// should minimize it.
|
||||
if (!pthread_equal(uwsgi.workers[uwsgi.mywid].cores[0].thread_id, pthread_self())) {
|
||||
if (pthread_cancel(uwsgi.workers[uwsgi.mywid].cores[0].thread_id)) {
|
||||
uwsgi_error("pthread_cancel() on initial thread\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = pthread_join(uwsgi.workers[uwsgi.mywid].cores[0].thread_id, NULL);
|
||||
if (ret) {
|
||||
uwsgi_log("pthread_join() = %d on initial thread\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
pthread_mutex_unlock(&uwsgi.six_feet_under_lock);
|
||||
@@ -2262,7 +2284,7 @@ void uwsgi_setup(int argc, char *argv[], char *envp[]) {
|
||||
uwsgi_opt_flock(NULL, uwsgi.flock_wait2, NULL);
|
||||
|
||||
// setup master logging
|
||||
if (uwsgi.log_master)
|
||||
if (uwsgi.log_master && !uwsgi.daemonize2)
|
||||
uwsgi_setup_log_master();
|
||||
|
||||
// setup offload engines
|
||||
@@ -2542,6 +2564,11 @@ int uwsgi_start(void *v_argv) {
|
||||
uwsgi_as_root();
|
||||
}
|
||||
|
||||
// wait for socket
|
||||
uwsgi_foreach(usl, uwsgi.wait_for_socket) {
|
||||
if (uwsgi_wait_for_socket(usl->value)) exit(1);
|
||||
}
|
||||
|
||||
if (uwsgi.logto2) {
|
||||
if (!uwsgi.is_a_reload || uwsgi.log_reopen) {
|
||||
logto(uwsgi.logto2);
|
||||
@@ -3210,6 +3237,24 @@ next2:
|
||||
|
||||
}
|
||||
|
||||
// this lives in a worker thread and periodically scans for memory usage
|
||||
// when evil reloaders are in place
|
||||
void *mem_collector(void *foobar) {
|
||||
// block all signals
|
||||
sigset_t smask;
|
||||
sigfillset(&smask);
|
||||
pthread_sigmask(SIG_BLOCK, &smask, NULL);
|
||||
uwsgi_log_verbose("mem-collector thread started for worker %d\n", uwsgi.mywid);
|
||||
for(;;) {
|
||||
sleep(uwsgi.mem_collector_freq);
|
||||
uint64_t rss, vsz;
|
||||
get_memusage(&rss, &vsz);
|
||||
uwsgi.workers[uwsgi.mywid].rss_size = rss;
|
||||
uwsgi.workers[uwsgi.mywid].vsz_size = vsz;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int uwsgi_run() {
|
||||
|
||||
// !!! from now on, we could be in the master or in a worker !!!
|
||||
@@ -3236,6 +3281,11 @@ int uwsgi_run() {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (uwsgi.evil_reload_on_rss || uwsgi.evil_reload_on_as) {
|
||||
pthread_t t;
|
||||
pthread_create(&t, NULL, mem_collector, NULL);
|
||||
}
|
||||
|
||||
|
||||
// eventually maps (or disable) sockets for the worker
|
||||
uwsgi_map_sockets();
|
||||
@@ -4413,6 +4463,7 @@ int uwsgi_zerg_attach(char *value) {
|
||||
|
||||
if (zerg == NULL) {
|
||||
uwsgi_log("--- invalid data received from zerg-server ---\n");
|
||||
close(zerg_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -4708,7 +4759,7 @@ extern char *uwsgi_dot_h;
|
||||
char *uwsgi_get_dot_h() {
|
||||
char *src = uwsgi_dot_h;
|
||||
size_t len = strlen(src);
|
||||
char *ptr = uwsgi_malloc(len / 2);
|
||||
char *ptr = uwsgi_malloc((len / 2) + 1);
|
||||
char *base = ptr;
|
||||
size_t i;
|
||||
unsigned int u;
|
||||
@@ -4729,6 +4780,9 @@ char *uwsgi_get_dot_h() {
|
||||
base = ub->buf;
|
||||
ub->buf = NULL;
|
||||
uwsgi_buffer_destroy(ub);
|
||||
#else
|
||||
// add final null byte
|
||||
*ptr = '\0';
|
||||
#endif
|
||||
return base;
|
||||
}
|
||||
@@ -4741,7 +4795,7 @@ extern char *uwsgi_config_py;
|
||||
char *uwsgi_get_config_py() {
|
||||
char *src = uwsgi_config_py;
|
||||
size_t len = strlen(src);
|
||||
char *ptr = uwsgi_malloc(len / 2);
|
||||
char *ptr = uwsgi_malloc((len / 2) + 1);
|
||||
char *base = ptr;
|
||||
size_t i;
|
||||
unsigned int u;
|
||||
@@ -4762,6 +4816,9 @@ char *uwsgi_get_config_py() {
|
||||
base = ub->buf;
|
||||
ub->buf = NULL;
|
||||
uwsgi_buffer_destroy(ub);
|
||||
#else
|
||||
// add final null byte
|
||||
*ptr = '\0';
|
||||
#endif
|
||||
return base;
|
||||
}
|
||||
|
||||
@@ -533,9 +533,9 @@ static int uwsgi_cgi_request(struct wsgi_request *wsgi_req) {
|
||||
memcpy(full_path, tmp_path, full_path_len+1);
|
||||
|
||||
if (uwsgi_starts_with(full_path, full_path_len, docroot, docroot_len)) {
|
||||
uwsgi_log("CGI security error: %s is not under %s\n", full_path, docroot);
|
||||
if (need_free)
|
||||
free(docroot);
|
||||
uwsgi_log("CGI security error: %s is not under %s\n", full_path, docroot);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ int uwsgi_cr_peer_del(struct corerouter_peer *peer) {
|
||||
if (peer->flush && !peer->is_flushing) {
|
||||
peer->is_flushing = 1;
|
||||
// on success, suspend the execution
|
||||
if (peer->flush(peer) >= 0) return -1;
|
||||
if (peer->flush(peer) > 0) return -1;
|
||||
}
|
||||
struct corerouter_peer *prev = peer->prev;
|
||||
struct corerouter_peer *next = peer->next;
|
||||
|
||||
@@ -222,8 +222,8 @@ static ssize_t fr_instance_connected(struct corerouter_peer *peer) {
|
||||
peer->can_retry = 0;
|
||||
|
||||
// fix modifiers
|
||||
peer->in->buf[0] = peer->modifier1;
|
||||
peer->in->buf[3] = peer->modifier2;
|
||||
peer->session->main_peer->in->buf[0] = peer->modifier1;
|
||||
peer->session->main_peer->in->buf[3] = peer->modifier2;
|
||||
|
||||
// prepare to write the uwsgi packet
|
||||
peer->out = peer->session->main_peer->in;
|
||||
|
||||
@@ -320,7 +320,8 @@ ssize_t hr_ssl_write(struct corerouter_peer *main_peer) {
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SYSCALL) {
|
||||
uwsgi_cr_error(main_peer, "hr_ssl_write()");
|
||||
if (errno != 0)
|
||||
uwsgi_cr_error(main_peer, "hr_ssl_write()");
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SSL && uwsgi.ssl_verbose) {
|
||||
@@ -380,7 +381,8 @@ ssize_t hr_ssl_read(struct corerouter_peer *main_peer) {
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SYSCALL) {
|
||||
uwsgi_cr_error(main_peer, "hr_ssl_read()");
|
||||
if (errno != 0)
|
||||
uwsgi_cr_error(main_peer, "hr_ssl_read()");
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SSL && uwsgi.ssl_verbose) {
|
||||
@@ -420,7 +422,8 @@ ssize_t hr_ssl_shutdown(struct corerouter_peer *peer) {
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SYSCALL) {
|
||||
uwsgi_cr_error(peer, "hr_ssl_shutdown()");
|
||||
if (errno != 0)
|
||||
uwsgi_cr_error(peer, "hr_ssl_shutdown()");
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SSL && uwsgi.ssl_verbose) {
|
||||
|
||||
@@ -11,8 +11,8 @@ XS(XS_input_seek) {
|
||||
dXSARGS;
|
||||
struct wsgi_request *wsgi_req = current_wsgi_req();
|
||||
|
||||
psgi_check_args(1);
|
||||
uwsgi_request_body_seek(wsgi_req, SvIV(ST(0)));
|
||||
psgi_check_args(2);
|
||||
uwsgi_request_body_seek(wsgi_req, SvIV(ST(1)));
|
||||
|
||||
XSRETURN(0);
|
||||
}
|
||||
@@ -144,7 +144,7 @@ XS(XS_input_read) {
|
||||
else {
|
||||
long orig_offset = 0;
|
||||
// first of all get the new orig_len;
|
||||
offset = abs(offset);
|
||||
offset = labs(offset);
|
||||
if (offset > (long) orig_len) {
|
||||
new_size = offset;
|
||||
orig_offset = offset - orig_len;
|
||||
@@ -285,7 +285,7 @@ nonworker:
|
||||
uwsgi_log("[perl] WARNING !!! unable to build uwsgi::opt hash !!!\n");
|
||||
goto end;
|
||||
}
|
||||
if (SvTYPE(SvRV(*value)) == SVt_PVAV) {
|
||||
if (SvROK(*value) && SvTYPE(SvRV(*value)) == SVt_PVAV) {
|
||||
if (uwsgi.exported_opts[i]->value == NULL) {
|
||||
av_push((AV *)SvRV(*value), newSViv(1));
|
||||
}
|
||||
@@ -302,15 +302,15 @@ nonworker:
|
||||
else {
|
||||
av_push(_opt_a, newSVpv(uwsgi.exported_opts[i]->value, 0));
|
||||
}
|
||||
hv_store(_opts, uwsgi.exported_opts[i]->key, strlen(uwsgi.exported_opts[i]->key), newRV_inc((SV *) _opt_a), 0);
|
||||
(void ) hv_store(_opts, uwsgi.exported_opts[i]->key, strlen(uwsgi.exported_opts[i]->key), newRV_inc((SV *) _opt_a), 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (uwsgi.exported_opts[i]->value == NULL) {
|
||||
hv_store(_opts, uwsgi.exported_opts[i]->key, strlen(uwsgi.exported_opts[i]->key), newSViv(1), 0);
|
||||
(void )hv_store(_opts, uwsgi.exported_opts[i]->key, strlen(uwsgi.exported_opts[i]->key), newSViv(1), 0);
|
||||
}
|
||||
else {
|
||||
hv_store(_opts, uwsgi.exported_opts[i]->key, strlen(uwsgi.exported_opts[i]->key), newSVpv(uwsgi.exported_opts[i]->value, 0), 0);
|
||||
(void)hv_store(_opts, uwsgi.exported_opts[i]->key, strlen(uwsgi.exported_opts[i]->key), newSVpv(uwsgi.exported_opts[i]->value, 0), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,6 +637,19 @@ void uwsgi_perl_after_request(struct wsgi_request *wsgi_req) {
|
||||
// before the environ is set up.
|
||||
if (!wsgi_req->async_environ) return;
|
||||
|
||||
// we need to restore the context in case of multiple interpreters
|
||||
struct uwsgi_app *wi = &uwsgi_apps[wsgi_req->app_id];
|
||||
if (uwsgi.threads < 2) {
|
||||
if (((PerlInterpreter **)wi->interpreter)[0] != uperl.main[0]) {
|
||||
PERL_SET_CONTEXT(((PerlInterpreter **)wi->interpreter)[0]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (((PerlInterpreter **)wi->interpreter)[wsgi_req->async_id] != uperl.main[wsgi_req->async_id]) {
|
||||
PERL_SET_CONTEXT(((PerlInterpreter **)wi->interpreter)[wsgi_req->async_id]);
|
||||
}
|
||||
}
|
||||
|
||||
// dereference %env
|
||||
SV *env = SvRV((SV *) wsgi_req->async_environ);
|
||||
|
||||
@@ -684,6 +697,19 @@ void uwsgi_perl_after_request(struct wsgi_request *wsgi_req) {
|
||||
}
|
||||
}
|
||||
|
||||
// restore main interpreter if needed
|
||||
if (uwsgi.threads > 1) {
|
||||
if (((PerlInterpreter **)wi->interpreter)[wsgi_req->async_id] != uperl.main[wsgi_req->async_id]) {
|
||||
PERL_SET_CONTEXT(uperl.main[wsgi_req->async_id]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (((PerlInterpreter **)wi->interpreter)[0] != uperl.main[0]) {
|
||||
PERL_SET_CONTEXT(uperl.main[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
int uwsgi_perl_magic(char *mountpoint, char *lazy) {
|
||||
|
||||
+12
-12
@@ -393,7 +393,7 @@ class WSGIinput(object):
|
||||
rlen = ffi.new('ssize_t*')
|
||||
chunk = lib.uwsgi_request_body_read(self.wsgi_req, size, rlen)
|
||||
if chunk != ffi.NULL:
|
||||
return ffi.string(chunk, rlen[0])
|
||||
return ffi.buffer(chunk, rlen[0])[:]
|
||||
if rlen[0] < 0:
|
||||
raise IOError("error reading wsgi.input")
|
||||
raise IOError("error waiting for wsgi.input")
|
||||
@@ -402,7 +402,7 @@ class WSGIinput(object):
|
||||
rlen = ffi.new('ssize_t*')
|
||||
chunk = lib.uwsgi_request_body_readline(self.wsgi_req, hint, rlen)
|
||||
if chunk != ffi.NULL:
|
||||
return ffi.string(chunk, rlen[0])
|
||||
return ffi.buffer(chunk, rlen[0])[:]
|
||||
if rlen[0] < 0:
|
||||
raise IOError("error reading line from wsgi.input")
|
||||
raise IOError("error waiting for line on wsgi.input")
|
||||
@@ -521,7 +521,7 @@ class uwsgi_pypy_RPC(object):
|
||||
def __call__(self, argc, argv, argvs, buf):
|
||||
pargs = []
|
||||
for i in range(0, argc):
|
||||
pargs.append(ffi.string(argv[i], argvs[i]))
|
||||
pargs.append(ffi.buffer(argv[i], argvs[i])[:])
|
||||
response = self.func(*pargs)
|
||||
if len(response) > 0:
|
||||
buf[0] = lib.uwsgi_malloc(len(response))
|
||||
@@ -560,7 +560,7 @@ def uwsgi_pypy_rpc(node, func, *args):
|
||||
|
||||
response = lib.uwsgi_do_rpc(c_node, ffi.new("char[]",func), argc, argv, argvs, rsize)
|
||||
if response:
|
||||
ret = ffi.string(response, rsize[0])
|
||||
ret = ffi.buffer(response, rsize[0])[:]
|
||||
lib.free(response)
|
||||
return ret
|
||||
return None
|
||||
@@ -587,7 +587,7 @@ def uwsgi_pypy_uwsgi_cache_get(key, cache=ffi.NULL):
|
||||
value = lib.uwsgi_cache_magic_get(key, len(key), vallen, ffi.NULL, cache)
|
||||
if value == ffi.NULL:
|
||||
return None
|
||||
ret = ffi.string(value, vallen[0])
|
||||
ret = ffi.buffer(value, vallen[0])[:]
|
||||
libc.free(value)
|
||||
return ret
|
||||
uwsgi.cache_get = uwsgi_pypy_uwsgi_cache_get
|
||||
@@ -617,8 +617,9 @@ def uwsgi_pypy_uwsgi_cache_keys(cache=ffi.NULL):
|
||||
uci = ffi.new('struct uwsgi_cache_item **')
|
||||
while True:
|
||||
uci[0] = lib.uwsgi_cache_keys(uc, pos, uci)
|
||||
if uci[0] == ffi.NULL: break
|
||||
l.append(ffi.string(lib.uwsgi_cache_item_key(uci[0]), uci[0].keysize))
|
||||
if uci[0] == ffi.NULL:
|
||||
break
|
||||
l.append(ffi.buffer(lib.uwsgi_cache_item_key(uci[0]), uci[0].keysize)[:])
|
||||
lib.uwsgi_cache_rwunlock(uc)
|
||||
return l
|
||||
uwsgi.cache_keys = uwsgi_pypy_uwsgi_cache_keys
|
||||
@@ -849,7 +850,7 @@ def uwsgi_pypy_websocket_recv():
|
||||
ub = lib.uwsgi_websocket_recv(wsgi_req);
|
||||
if ub == ffi.NULL:
|
||||
raise IOError("unable to receive websocket message")
|
||||
ret = ffi.string(ub.buf, ub.pos)
|
||||
ret = ffi.buffer(ub.buf, ub.pos)[:]
|
||||
lib.uwsgi_buffer_destroy(ub)
|
||||
return ret
|
||||
uwsgi.websocket_recv = uwsgi_pypy_websocket_recv
|
||||
@@ -862,7 +863,7 @@ def uwsgi_pypy_websocket_recv_nb():
|
||||
ub = lib.uwsgi_websocket_recv_nb(wsgi_req);
|
||||
if ub == ffi.NULL:
|
||||
raise IOError("unable to receive websocket message")
|
||||
ret = ffi.string(ub.buf, ub.pos)
|
||||
ret = ffi.buffer(ub.buf, ub.pos)[:]
|
||||
lib.uwsgi_buffer_destroy(ub)
|
||||
return ret
|
||||
uwsgi.websocket_recv_nb = uwsgi_pypy_websocket_recv_nb
|
||||
@@ -897,7 +898,7 @@ def uwsgi_pypy_chunked_read(timeout=0):
|
||||
chunk = lib.uwsgi_chunked_read(wsgi_req, rlen, timeout, 0)
|
||||
if chunk == ffi.NULL:
|
||||
raise IOError("unable to receive chunked part")
|
||||
return ffi.string(chunk, rlen[0])
|
||||
return ffi.buffer(chunk, rlen[0])[:]
|
||||
uwsgi.chunked_read = uwsgi_pypy_chunked_read
|
||||
|
||||
"""
|
||||
@@ -911,8 +912,7 @@ def uwsgi_pypy_chunked_read_nb():
|
||||
if lib.uwsgi_is_again() > 0:
|
||||
return None
|
||||
raise IOError("unable to receive chunked part")
|
||||
|
||||
return ffi.string(chunk, rlen[0])
|
||||
return ffi.buffer(chunk, rlen[0])[:]
|
||||
uwsgi.chunked_read_nb = uwsgi_pypy_chunked_read_nb
|
||||
|
||||
"""
|
||||
|
||||
@@ -88,7 +88,7 @@ struct uwsgi_option uwsgi_python_options[] = {
|
||||
{"module", required_argument,'w', "load a WSGI module", uwsgi_opt_set_str, &up.wsgi_config, 0},
|
||||
{"wsgi", required_argument, 'w', "load a WSGI module", uwsgi_opt_set_str, &up.wsgi_config, 0},
|
||||
{"callable", required_argument, 0, "set default WSGI callable name", uwsgi_opt_set_str, &up.callable, 0},
|
||||
{"test", required_argument, 'J', "test a mdule import", uwsgi_opt_set_str, &up.test_module, 0},
|
||||
{"test", required_argument, 'J', "test a module import", uwsgi_opt_set_str, &up.test_module, 0},
|
||||
{"home", required_argument, 'H', "set PYTHONHOME/virtualenv", uwsgi_opt_set_str, &up.home, 0},
|
||||
{"virtualenv", required_argument, 'H', "set PYTHONHOME/virtualenv", uwsgi_opt_set_str, &up.home, 0},
|
||||
{"venv", required_argument, 'H', "set PYTHONHOME/virtualenv", uwsgi_opt_set_str, &up.home, 0},
|
||||
@@ -1670,6 +1670,8 @@ int uwsgi_python_spooler(char *filename, char *buf, uint16_t len, char *body, si
|
||||
PyDict_SetItemString(spool_dict, "body", value);
|
||||
Py_DECREF(value);
|
||||
}
|
||||
// PyTuple_SetItem steals a reference !!!
|
||||
Py_INCREF(spool_dict);
|
||||
PyTuple_SetItem(pyargs, 0, spool_dict);
|
||||
|
||||
ret = python_call(spool_func, pyargs, 0, NULL);
|
||||
|
||||
@@ -1448,6 +1448,72 @@ PyObject *py_uwsgi_sharedarea_inc64(PyObject * self, PyObject * args) {
|
||||
|
||||
}
|
||||
|
||||
PyObject *py_uwsgi_sharedarea_inc32(PyObject * self, PyObject * args) {
|
||||
int id;
|
||||
uint64_t pos = 0;
|
||||
int32_t value = 1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iL|i:sharedarea_inc32", &id, &pos, &value)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UWSGI_RELEASE_GIL
|
||||
int ret = uwsgi_sharedarea_inc32(id, pos, value);
|
||||
UWSGI_GET_GIL
|
||||
|
||||
if (ret) {
|
||||
return PyErr_Format(PyExc_ValueError, "error calling uwsgi_sharedarea_inc32()");
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
|
||||
}
|
||||
|
||||
PyObject *py_uwsgi_sharedarea_dec64(PyObject * self, PyObject * args) {
|
||||
int id;
|
||||
uint64_t pos = 0;
|
||||
int64_t value = 1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iL|l:sharedarea_dec64", &id, &pos, &value)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UWSGI_RELEASE_GIL
|
||||
int ret = uwsgi_sharedarea_dec64(id, pos, value);
|
||||
UWSGI_GET_GIL
|
||||
|
||||
if (ret) {
|
||||
return PyErr_Format(PyExc_ValueError, "error calling uwsgi_sharedarea_dec64()");
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
|
||||
}
|
||||
|
||||
PyObject *py_uwsgi_sharedarea_dec32(PyObject * self, PyObject * args) {
|
||||
int id;
|
||||
uint64_t pos = 0;
|
||||
int32_t value = 1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iL|i:sharedarea_dec32", &id, &pos, &value)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UWSGI_RELEASE_GIL
|
||||
int ret = uwsgi_sharedarea_dec32(id, pos, value);
|
||||
UWSGI_GET_GIL
|
||||
|
||||
if (ret) {
|
||||
return PyErr_Format(PyExc_ValueError, "error calling uwsgi_sharedarea_dec32()");
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
|
||||
}
|
||||
|
||||
PyObject *py_uwsgi_sharedarea_write32(PyObject * self, PyObject * args) {
|
||||
int id;
|
||||
uint64_t pos = 0;
|
||||
@@ -2569,6 +2635,9 @@ static PyMethodDef uwsgi_sa_methods[] = {
|
||||
{"sharedarea_write16", py_uwsgi_sharedarea_write16, METH_VARARGS, ""},
|
||||
{"sharedarea_inclong", py_uwsgi_sharedarea_inc64, METH_VARARGS, ""},
|
||||
{"sharedarea_inc64", py_uwsgi_sharedarea_inc64, METH_VARARGS, ""},
|
||||
{"sharedarea_inc32", py_uwsgi_sharedarea_inc32, METH_VARARGS, ""},
|
||||
{"sharedarea_dec64", py_uwsgi_sharedarea_dec64, METH_VARARGS, ""},
|
||||
{"sharedarea_dec32", py_uwsgi_sharedarea_dec32, METH_VARARGS, ""},
|
||||
{"sharedarea_rlock", py_uwsgi_sharedarea_rlock, METH_VARARGS, ""},
|
||||
{"sharedarea_wlock", py_uwsgi_sharedarea_wlock, METH_VARARGS, ""},
|
||||
{"sharedarea_unlock", py_uwsgi_sharedarea_unlock, METH_VARARGS, ""},
|
||||
|
||||
@@ -31,7 +31,12 @@ ssize_t uwsgi_rsyslog_logger(struct uwsgi_logger *ul, char *message, size_t len)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ul->fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (ul->arg[0] == '/') {
|
||||
ul->fd = socket(AF_UNIX, SOCK_DGRAM, 0);
|
||||
}
|
||||
else {
|
||||
ul->fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
}
|
||||
if (ul->fd < 0) {
|
||||
uwsgi_error_safe("socket()");
|
||||
exit(1);
|
||||
@@ -62,7 +67,12 @@ ssize_t uwsgi_rsyslog_logger(struct uwsgi_logger *ul, char *message, size_t len)
|
||||
*port = 0;
|
||||
}
|
||||
|
||||
ul->addr_len = socket_to_in_addr(ul->arg, NULL, portn, &ul->addr.sa_in);
|
||||
if (ul->arg[0] == '/') {
|
||||
ul->addr_len = socket_to_un_addr(ul->arg, &ul->addr.sa_un);
|
||||
}
|
||||
else {
|
||||
ul->addr_len = socket_to_in_addr(ul->arg, NULL, portn, &ul->addr.sa_in);
|
||||
}
|
||||
|
||||
if (port) *port = ':';
|
||||
if (comma) *comma = ',';
|
||||
|
||||
@@ -250,7 +250,8 @@ static ssize_t sr_write(struct corerouter_peer *main_peer) {
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SYSCALL) {
|
||||
uwsgi_cr_error(main_peer, "sr_write()");
|
||||
if (errno != 0)
|
||||
uwsgi_cr_error(main_peer, "sr_write()");
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SSL && uwsgi.ssl_verbose) {
|
||||
@@ -332,7 +333,8 @@ static ssize_t sr_read(struct corerouter_peer *main_peer) {
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SYSCALL) {
|
||||
uwsgi_cr_error(main_peer, "sr_ssl_read()");
|
||||
if (errno != 0)
|
||||
uwsgi_cr_error(main_peer, "sr_ssl_read()");
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SSL && uwsgi.ssl_verbose) {
|
||||
|
||||
@@ -24,7 +24,7 @@ static int transform_gzip(struct wsgi_request *wsgi_req, struct uwsgi_transforma
|
||||
struct uwsgi_buffer *ub = ut->chunk;
|
||||
|
||||
if (ut->is_final) {
|
||||
if (uwsgi_gzip_fix(&utgz->z, utgz->crc32, ub, utgz->len)) {
|
||||
if (utgz->len > 0 && uwsgi_gzip_fix(&utgz->z, utgz->crc32, ub, utgz->len)) {
|
||||
free(utgz);
|
||||
return -1;
|
||||
}
|
||||
@@ -32,6 +32,11 @@ static int transform_gzip(struct wsgi_request *wsgi_req, struct uwsgi_transforma
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ub->pos == 0) {
|
||||
// Don't try to compress empty responses.
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t dlen = 0;
|
||||
char *gzipped = uwsgi_gzip_chunk(&utgz->z, &utgz->crc32, ub->buf, ub->pos, &dlen);
|
||||
if (!gzipped) return -1;
|
||||
@@ -39,7 +44,7 @@ static int transform_gzip(struct wsgi_request *wsgi_req, struct uwsgi_transforma
|
||||
uwsgi_buffer_map(ub, gzipped, dlen);
|
||||
if (!utgz->header) {
|
||||
// do not check for errors !!!
|
||||
uwsgi_response_add_header(wsgi_req, "Content-Encoding", 16, "gzip", 4);
|
||||
uwsgi_response_add_header(wsgi_req, "Content-Encoding", 16, "gzip", 4);
|
||||
utgz->header = 1;
|
||||
if (uwsgi_buffer_insert(ub, 0, gzheader, 10)) {
|
||||
return -1;
|
||||
@@ -59,7 +64,7 @@ static int uwsgi_routing_func_gzip(struct wsgi_request *wsgi_req, struct uwsgi_r
|
||||
ut->can_stream = 1;
|
||||
// this is the trasformation clearing the memory
|
||||
ut = uwsgi_add_transformation(wsgi_req, transform_gzip, utgz);
|
||||
ut->is_final = 1;
|
||||
ut->is_final = 1;
|
||||
return UWSGI_ROUTE_NEXT;
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -287,7 +287,8 @@ retry:
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SYSCALL) {
|
||||
uwsgi_error("uwsgi_proto_ssl_write()/SSL_write()");
|
||||
if (errno != 0)
|
||||
uwsgi_error("uwsgi_proto_ssl_write()/SSL_write()");
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -383,7 +384,8 @@ retry:
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SYSCALL) {
|
||||
uwsgi_error("uwsgi_proto_ssl_read_body()/SSL_read()");
|
||||
if (errno != 0)
|
||||
uwsgi_error("uwsgi_proto_ssl_read_body()/SSL_read()");
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
+2
-1
@@ -760,7 +760,8 @@ retry:
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SYSCALL) {
|
||||
uwsgi_error("uwsgi_proto_https_parser()/SSL_read()");
|
||||
if (errno != 0)
|
||||
uwsgi_error("uwsgi_proto_https_parser()/SSL_read()");
|
||||
}
|
||||
return -1;
|
||||
empty:
|
||||
|
||||
+2
-1
@@ -83,7 +83,8 @@ retry:
|
||||
}
|
||||
|
||||
else if (err == SSL_ERROR_SYSCALL) {
|
||||
uwsgi_error("uwsgi_proto_suwsgi_parser()/SSL_read()");
|
||||
if (errno != 0)
|
||||
uwsgi_error("uwsgi_proto_suwsgi_parser()/SSL_read()");
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# uwsgi --route-run remheader:Content-Length --route-run forcecl: --wsgi-file t/python/forcecl.py --http-socket :9090
|
||||
def application(e, sr):
|
||||
sr('200 OK', [('Content-Length', '1'), ('Content-Length', '2')])
|
||||
return ['xxx']
|
||||
@@ -0,0 +1,6 @@
|
||||
[uwsgi]
|
||||
socket = /tmp/foo
|
||||
|
||||
sharedarea = size=4300000000
|
||||
|
||||
pyrun = t/sharedarea/%n.py
|
||||
@@ -0,0 +1,16 @@
|
||||
import uwsgi
|
||||
import unittest
|
||||
|
||||
class SharedareaTest(unittest.TestCase):
|
||||
|
||||
def test_32(self):
|
||||
pos = 2L * (1024L ** 3)
|
||||
uwsgi.sharedarea_write32(0, pos, 17)
|
||||
self.assertEqual(uwsgi.sharedarea_read32(0, pos), 17)
|
||||
|
||||
def test_64(self):
|
||||
pos = 2L * (1024L ** 3)
|
||||
uwsgi.sharedarea_write64(0, pos, 30)
|
||||
self.assertEqual(uwsgi.sharedarea_read64(0, pos), 30)
|
||||
|
||||
unittest.main()
|
||||
@@ -0,0 +1,6 @@
|
||||
[uwsgi]
|
||||
socket = /tmp/foo
|
||||
|
||||
sharedarea = size=64
|
||||
|
||||
pyrun = t/sharedarea/%n.py
|
||||
@@ -0,0 +1,34 @@
|
||||
import uwsgi
|
||||
import unittest
|
||||
|
||||
class SharedareaTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
uwsgi.sharedarea_write(0, 0, '\0' * 64)
|
||||
|
||||
def test_32(self):
|
||||
uwsgi.sharedarea_write32(0, 0, 17)
|
||||
self.assertEqual(uwsgi.sharedarea_read32(0, 0), 17)
|
||||
|
||||
def test_inc32(self):
|
||||
uwsgi.sharedarea_write32(0, 4, 30)
|
||||
uwsgi.sharedarea_inc32(0, 4, 3)
|
||||
self.assertEqual(uwsgi.sharedarea_read32(0, 4), 33)
|
||||
|
||||
def test_dec32(self):
|
||||
uwsgi.sharedarea_write32(0, 5, 30)
|
||||
uwsgi.sharedarea_dec32(0, 5, 4)
|
||||
self.assertEqual(uwsgi.sharedarea_read32(0, 5), 26)
|
||||
|
||||
def test_inc64(self):
|
||||
uwsgi.sharedarea_write64(0, 8, 17 * (1024 ** 5))
|
||||
uwsgi.sharedarea_inc64(0, 8, 1)
|
||||
self.assertEqual(uwsgi.sharedarea_read64(0, 8), 17 * (1024 ** 5) + 1)
|
||||
|
||||
def test_dec64(self):
|
||||
uwsgi.sharedarea_write64(0, 8, 30 * (1024 ** 5))
|
||||
uwsgi.sharedarea_dec64(0, 8, 30 * (1024 ** 5) - 1)
|
||||
self.assertEqual(uwsgi.sharedarea_read64(0, 8), 1)
|
||||
|
||||
|
||||
unittest.main()
|
||||
+1
-1
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
|
||||
s.name = 'uwsgi'
|
||||
s.license = 'GPL-2'
|
||||
s.version = `python -c "import uwsgiconfig as uc; print uc.uwsgi_version"`.sub(/-dev-.*/,'')
|
||||
s.date = '2014-12-30'
|
||||
s.date = '2015-10-07'
|
||||
s.summary = "uWSGI"
|
||||
s.description = "The uWSGI server for Ruby/Rack"
|
||||
s.authors = ["Unbit"]
|
||||
|
||||
@@ -2757,6 +2757,14 @@ struct uwsgi_server {
|
||||
char *subscribe_with_modifier1;
|
||||
struct uwsgi_string_list *pull_headers;
|
||||
|
||||
// uWSGI 2.0.10
|
||||
struct uwsgi_string_list *emperor_wrapper_override;
|
||||
struct uwsgi_string_list *emperor_wrapper_fallback;
|
||||
|
||||
// uWSGI 2.0.11
|
||||
struct uwsgi_string_list *wait_for_socket;
|
||||
int wait_for_socket_timeout;
|
||||
int mem_collector_freq;
|
||||
};
|
||||
|
||||
struct uwsgi_rpc {
|
||||
@@ -3466,6 +3474,7 @@ struct uwsgi_socket *uwsgi_new_shared_socket(char *);
|
||||
struct uwsgi_socket *uwsgi_del_socket(struct uwsgi_socket *);
|
||||
|
||||
void uwsgi_close_all_sockets(void);
|
||||
void uwsgi_close_all_unshared_sockets(void);
|
||||
|
||||
struct uwsgi_string_list *uwsgi_string_new_list(struct uwsgi_string_list **, char *);
|
||||
#ifdef UWSGI_PCRE
|
||||
@@ -4849,6 +4858,7 @@ void vassal_sos();
|
||||
|
||||
int uwsgi_wait_for_fs(char *, int);
|
||||
int uwsgi_wait_for_mountpoint(char *);
|
||||
int uwsgi_wait_for_socket(char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+10
-5
@@ -1,6 +1,6 @@
|
||||
# uWSGI build system
|
||||
|
||||
uwsgi_version = '2.0.9'
|
||||
uwsgi_version = '2.0.11.2'
|
||||
|
||||
import os
|
||||
import re
|
||||
@@ -689,8 +689,13 @@ class uConf(object):
|
||||
print("detected include path: %s" % self.include_path)
|
||||
|
||||
try:
|
||||
gcc_major = int(gcc_version.split('.')[0])
|
||||
gcc_minor = int(gcc_version.split('.')[1])
|
||||
gcc_version_components = gcc_version.split('.')
|
||||
gcc_major = int(gcc_version_components[0])
|
||||
if len(gcc_version_components) > 1:
|
||||
gcc_minor = int(gcc_version_components[1])
|
||||
else:
|
||||
# gcc 5.0 is represented as simply "5"
|
||||
gcc_minor = 0
|
||||
except:
|
||||
raise Exception("you need a C compiler to build uWSGI")
|
||||
if (sys.version_info[0] == 2) or (gcc_major < 4) or (gcc_major == 4 and gcc_minor < 3):
|
||||
@@ -698,7 +703,7 @@ class uConf(object):
|
||||
# add -fno-strict-aliasing only on python2 and gcc < 4.3
|
||||
if gcc_major >= 4:
|
||||
self.cflags = self.cflags + [ '-Wextra', '-Wno-unused-parameter', '-Wno-missing-field-initializers' ]
|
||||
if (gcc_major == 4 and gcc_minor >= 8) or gcc_major > 4:
|
||||
if gcc_major == 4 and gcc_minor < 9:
|
||||
self.cflags.append('-Wno-format -Wno-format-security')
|
||||
|
||||
self.ldflags = os.environ.get("LDFLAGS", "").split()
|
||||
@@ -768,7 +773,7 @@ class uConf(object):
|
||||
|
||||
if 'UWSGI_PROFILE_OVERRIDE' in os.environ:
|
||||
for item in os.environ['UWSGI_PROFILE_OVERRIDE'].split(';'):
|
||||
k,v = item.split('=', 2)
|
||||
k,v = item.split('=', 1)
|
||||
self.set(k, v)
|
||||
|
||||
if 'UWSGI_AS_LIB' in os.environ:
|
||||
|
||||
Reference in New Issue
Block a user