Compare commits

...
11 Commits
23 changed files with 286 additions and 86 deletions
+9
View File
@@ -1,5 +1,14 @@
*** current ***
* 1.4.1
- fixed typos in corerouter plugins
- fixed offloading when the number of threads is higher than 1
- fixed static_maps for non-existent paths
- fixed uwsgi_connect() on modern Linux systems to reset the socket to blocking mode
*** november 2012 ***
* 1.4
- gevent improvements
+1
View File
@@ -92,6 +92,7 @@ void uwsgi_ini_config(char *file, char *magic_table[]) {
char *section_asked = "uwsgi";
char *colon;
if (uwsgi_check_scheme(file)) {
colon = uwsgi_get_last_char(file, '/');
colon = uwsgi_get_last_char(colon, ':');
+19 -18
View File
@@ -107,7 +107,7 @@ error:
return -1;
}
static void uwsgi_offload_close(struct uwsgi_offload_request *uor) {
static void uwsgi_offload_close(struct uwsgi_thread *ut, struct uwsgi_offload_request *uor) {
// close the socket and the file descriptor
close(uor->s);
close(uor->fd);
@@ -115,12 +115,12 @@ static void uwsgi_offload_close(struct uwsgi_offload_request *uor) {
struct uwsgi_offload_request *prev = uor->prev;
struct uwsgi_offload_request *next = uor->next;
if (uor == uwsgi.offload_requests_head) {
uwsgi.offload_requests_head = next;
if (uor == ut->offload_requests_head) {
ut->offload_requests_head = next;
}
if (uor == uwsgi.offload_requests_tail) {
uwsgi.offload_requests_tail = prev;
if (uor == ut->offload_requests_tail) {
ut->offload_requests_tail = prev;
}
if (prev) {
@@ -142,22 +142,22 @@ static void uwsgi_offload_close(struct uwsgi_offload_request *uor) {
free(uor);
}
static void uwsgi_offload_append(struct uwsgi_offload_request *uor) {
static void uwsgi_offload_append(struct uwsgi_thread *ut, struct uwsgi_offload_request *uor) {
if (!uwsgi.offload_requests_head) {
uwsgi.offload_requests_head = uor;
if (!ut->offload_requests_head) {
ut->offload_requests_head = uor;
}
if (uwsgi.offload_requests_tail) {
uwsgi.offload_requests_tail->next = uor;
uor->prev = uwsgi.offload_requests_tail;
if (ut->offload_requests_tail) {
ut->offload_requests_tail->next = uor;
uor->prev = ut->offload_requests_tail;
}
uwsgi.offload_requests_tail = uor;
ut->offload_requests_tail = uor;
}
static struct uwsgi_offload_request *uwsgi_offload_get_by_fd(int s) {
struct uwsgi_offload_request *uor = uwsgi.offload_requests_head;
static struct uwsgi_offload_request *uwsgi_offload_get_by_fd(struct uwsgi_thread *ut, int s) {
struct uwsgi_offload_request *uor = ut->offload_requests_head;
while (uor) {
if (uor->s == s || uor->fd == s) {
return uor;
@@ -187,20 +187,20 @@ static void uwsgi_offload_loop(struct uwsgi_thread *ut) {
}
// start monitoring socket for write
if (uor->func(ut, uor, -1)) {
uwsgi_offload_close(uor);
uwsgi_offload_close(ut, uor);
continue;
}
uwsgi_offload_append(uor);
uwsgi_offload_append(ut, uor);
continue;
}
// get the task from the interesting fd
struct uwsgi_offload_request *uor = uwsgi_offload_get_by_fd(interesting_fd);
struct uwsgi_offload_request *uor = uwsgi_offload_get_by_fd(ut, interesting_fd);
if (!uor)
continue;
// run the hook
if (uor->func(ut, uor, interesting_fd)) {
uwsgi_offload_close(uor);
uwsgi_offload_close(ut, uor);
}
}
}
@@ -234,6 +234,7 @@ static int uwsgi_offload_sendfile_transfer(struct uwsgi_thread *ut, struct uwsgi
if (uor->written >= uor->len) {
return -1;
}
return 0;
}
else if (len < 0) {
uwsgi_offload_retry
+16 -1
View File
@@ -1082,7 +1082,7 @@ nextcs:
udd = uwsgi.static_maps;
while (udd) {
#ifdef UWSGI_DEBUG
uwsgi_log("checking for %.*s <-> %.*s\n", wsgi_req->path_info_len, wsgi_req->path_info, udd->keylen, udd->key);
uwsgi_log("checking for %.*s <-> %.*s %.*s\n", (int)wsgi_req->path_info_len, wsgi_req->path_info, (int)udd->keylen, udd->key, (int) udd->vallen, udd->value);
#endif
if (udd->status == 0) {
#ifdef UWSGI_THREADING
@@ -1092,6 +1092,7 @@ nextcs:
char *real_docroot = uwsgi_malloc(PATH_MAX + 1);
if (!realpath(udd->value, real_docroot)) {
free(real_docroot);
real_docroot = NULL;
udd->value = NULL;
}
#ifdef UWSGI_THREADING
@@ -1128,6 +1129,7 @@ nextsm:
char *real_docroot = uwsgi_malloc(PATH_MAX + 1);
if (!realpath(udd->value, real_docroot)) {
free(real_docroot);
real_docroot = NULL;
udd->value = NULL;
}
#ifdef UWSGI_THREADING
@@ -1662,18 +1664,31 @@ char *uwsgi_req_append(struct wsgi_request *wsgi_req, char *key, uint16_t keylen
return NULL;
}
if (wsgi_req->var_cnt >= uwsgi.vec_size - (4 + 2)) {
uwsgi_log("max vec size reached. skip this header.\n");
return NULL;
}
char *ptr = wsgi_req->buffer + wsgi_req->uh.pktsize;
*ptr++ = (uint8_t) (keylen & 0xff);
*ptr++ = (uint8_t) ((keylen >> 8) & 0xff);
memcpy(ptr, key, keylen);
wsgi_req->hvec[wsgi_req->var_cnt].iov_base = ptr;
wsgi_req->hvec[wsgi_req->var_cnt].iov_len = keylen;
wsgi_req->var_cnt++;
ptr += keylen;
*ptr++ = (uint8_t) (vallen & 0xff);
*ptr++ = (uint8_t) ((vallen >> 8) & 0xff);
memcpy(ptr, val, vallen);
wsgi_req->hvec[wsgi_req->var_cnt].iov_base = ptr;
wsgi_req->hvec[wsgi_req->var_cnt].iov_len = vallen;
wsgi_req->var_cnt++;
wsgi_req->uh.pktsize += (2 + keylen + 2 + vallen);
+1 -1
View File
@@ -718,7 +718,7 @@ int timed_connect(struct pollfd *fdpoll, const struct sockaddr *addr, int addr_s
#if defined(__linux__) && defined(SOCK_NONBLOCK) && !defined(OBSOLETE_LINUX_KERNEL)
// hmm, nothing to do, as we are already non-blocking
uwsgi_socket_b(fdpoll->fd);
#else
/* re-set blocking socket */
arg &= (~O_NONBLOCK);
+3 -8
View File
@@ -2691,15 +2691,10 @@ void init_magic_table(char *magic_table[]) {
}
char *uwsgi_get_last_char(char *what, char c) {
int i, j = 0;
int i;
char *ptr = NULL;
if (!strncmp("http://", what, 7))
j = 7;
if (!strncmp("emperor://", what, 10))
j = 10;
for (i = j; i < (int) strlen(what); i++) {
for (i = 0; i < (int) strlen(what); i++) {
if (what[i] == c) {
ptr = what + i;
}
@@ -4806,7 +4801,7 @@ static void *uwsgi_thread_run(void *arg) {
struct uwsgi_thread *uwsgi_thread_new(void (*func) (struct uwsgi_thread *)) {
struct uwsgi_thread *ut = uwsgi_malloc(sizeof(struct uwsgi_thread));
struct uwsgi_thread *ut = uwsgi_calloc(sizeof(struct uwsgi_thread));
#if defined(SOCK_SEQPACKET) && defined(__linux__)
if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, ut->pipe)) {
+23 -10
View File
@@ -677,6 +677,17 @@ void config_magic_table_fill(char *filename, char **magic_table) {
char *tmp = NULL;
char *fullname = filename;
magic_table['o'] = filename;
if (uwsgi_check_scheme(filename) || !strcmp(filename, "-")) {
return;
}
char *section = uwsgi_get_last_char(filename, ':');
if (section) {
*section = 0;
}
// we have a special case for symlinks
if (uwsgi_is_link(filename)) {
if (filename[0] != '/') {
@@ -686,19 +697,16 @@ void config_magic_table_fill(char *filename, char **magic_table) {
else {
fullname = uwsgi_expand_path(filename, strlen(filename), NULL);
if (fullname) {
char *minimal_name = uwsgi_malloc(strlen(fullname) + 1);
memcpy(minimal_name, fullname, strlen(fullname));
minimal_name[strlen(fullname)] = 0;
free(fullname);
fullname = minimal_name;
}
else {
fullname = filename;
if (!fullname) {
exit(1);
}
char *minimal_name = uwsgi_malloc(strlen(fullname) + 1);
memcpy(minimal_name, fullname, strlen(fullname));
minimal_name[strlen(fullname)] = 0;
free(fullname);
fullname = minimal_name;
}
magic_table['o'] = filename;
magic_table['p'] = fullname;
magic_table['s'] = uwsgi_get_last_char(fullname, '/') + 1;
magic_table['d'] = uwsgi_concat2n(magic_table['p'], magic_table['s'] - magic_table['p'], "", 0);
@@ -732,6 +740,11 @@ void config_magic_table_fill(char *filename, char **magic_table) {
magic_table['e'] = uwsgi_get_last_char(filename, '.') + 1;
if (uwsgi_get_last_char(magic_table['s'], '.'))
magic_table['n'] = uwsgi_concat2n(magic_table['s'], uwsgi_get_last_char(magic_table['s'], '.') - magic_table['s'], "", 0);
if (section) {
magic_table['x'] = section+1;
*section = ':';
}
}
int find_worker_id(pid_t pid) {
+9 -3
View File
@@ -838,9 +838,15 @@ clear2:
uwsgi_error("setenv()");
}
if (setenv("PATH_TRANSLATED", uwsgi_concat3n(docroot, docroot_len, path_info, pi_len, "", 0) , 1)) {
uwsgi_error("setenv()");
if (wsgi_req->document_root_len > 0) {
if (setenv("PATH_TRANSLATED", uwsgi_concat3n(wsgi_req->document_root, wsgi_req->document_root_len, path_info, pi_len, "", 0) , 1)) {
uwsgi_error("setenv()");
}
}
else {
if (setenv("PATH_TRANSLATED", uwsgi_concat3n(docroot, docroot_len, path_info, pi_len, "", 0) , 1)) {
uwsgi_error("setenv()");
}
}
}
+4 -4
View File
@@ -567,7 +567,7 @@ struct corerouter_session *corerouter_alloc_session(struct uwsgi_corerouter *ucr
ucr->cr_table[new_connection]->fd = new_connection;
ucr->cr_table[new_connection]->instance_fd = -1;
// map courerouter and socket
// map corerouter and socket
ucr->cr_table[new_connection]->corerouter = ucr;
ucr->cr_table[new_connection]->ugs = ugs;
@@ -859,7 +859,7 @@ void uwsgi_corerouter_loop(int id, void *data) {
}
int uwsgi_courerouter_has_has_backends(struct uwsgi_corerouter *ucr) {
int uwsgi_corerouter_has_backends(struct uwsgi_corerouter *ucr) {
if (ucr->has_backends) return 1;
@@ -899,7 +899,7 @@ int uwsgi_corerouter_init(struct uwsgi_corerouter *ucr) {
ucr->max_retries = 3;
ucr->has_backends = uwsgi_courerouter_has_has_backends(ucr);
ucr->has_backends = uwsgi_corerouter_has_backends(ucr);
uwsgi_corerouter_setup_sockets(ucr);
@@ -923,7 +923,7 @@ int uwsgi_corerouter_init(struct uwsgi_corerouter *ucr) {
struct uwsgi_plugin corerouter_plugin = {
.name = "courerouter",
.name = "corerouter",
};
void corerouter_send_stats(struct uwsgi_corerouter *ucr) {
+1 -1
View File
@@ -185,7 +185,7 @@ int uwsgi_cr_map_use_cs(struct uwsgi_corerouter *, struct corerouter_session *);
int uwsgi_cr_map_use_to(struct uwsgi_corerouter *, struct corerouter_session *);
int uwsgi_cr_map_use_static_nodes(struct uwsgi_corerouter *, struct corerouter_session *);
int uwsgi_courerouter_has_has_backends(struct uwsgi_corerouter *);
int uwsgi_corerouter_has_backends(struct uwsgi_corerouter *);
int uwsgi_cr_hook_read(struct corerouter_session *, ssize_t (*)(struct corerouter_session *));
int uwsgi_cr_hook_write(struct corerouter_session *, ssize_t (*)(struct corerouter_session *));
+11 -3
View File
@@ -399,9 +399,9 @@ int http_parse(struct http_session *h_session, size_t http_req_len) {
while (ptr < watermark) {
if (*ptr == '\r') {
if (ptr + 1 >= watermark)
return 0;
break;
if (*(ptr + 1) != '\n')
return 0;
break;
// multiline header ?
if (ptr + 2 < watermark) {
if (*(ptr + 2) == ' ' || *(ptr + 2) == '\t') {
@@ -518,6 +518,14 @@ ssize_t hr_read_ssl_body(struct corerouter_session * cs) {
if (cs->event_hook_write) {
uwsgi_cr_hook_write(cs, NULL);
}
int ret2 = SSL_pending(hs->ssl);
if (ret2 > 0) {
if (uwsgi_buffer_fix(hs->post_buf, hs->post_buf->len + ret2 )) return -1;
if (SSL_read(hs->ssl, hs->post_buf->buf + ret, ret2) != ret2) {
return -1;
}
ret += ret2;
}
hs->post_buf_len = ret;
hs->post_buf_pos = 0;
uwsgi_cr_hook_read(cs, NULL);
@@ -1131,7 +1139,7 @@ int http_init() {
uhttp.cr.session_size = sizeof(struct http_session);
uhttp.cr.alloc_session = http_alloc_session;
if (uhttp.cr.has_sockets && !uwsgi.sockets && !uwsgi_courerouter_has_has_backends(&uhttp.cr)) {
if (uhttp.cr.has_sockets && !uwsgi.sockets && !uwsgi_corerouter_has_backends(&uhttp.cr)) {
uwsgi_new_socket(uwsgi_concat2("127.0.0.1:0", ""));
uhttp.cr.use_socket = 1;
uhttp.cr.socket_num = 0;
+3 -1
View File
@@ -308,6 +308,8 @@ static const luaL_reg uwsgi_api[] = {
static int uwsgi_lua_input(lua_State *L) {
struct wsgi_request *wsgi_req = current_wsgi_req();
int fd = wsgi_req->async_post ?
fileno(wsgi_req->async_post) : wsgi_req->poll.fd;
ssize_t sum, len, total;
char *buf, *ptr;
@@ -330,7 +332,7 @@ static int uwsgi_lua_input(lua_State *L) {
ptr = buf;
while(total) {
len = read(wsgi_req->poll.fd, ptr, total);
len = read(fd, ptr, total);
ptr += len;
total -= len;
}
+48 -1
View File
@@ -22,8 +22,10 @@ struct uwsgi_php {
struct uwsgi_string_list *index;
struct uwsgi_string_list *set;
struct uwsgi_string_list *append_config;
struct uwsgi_string_list *vars;
char *docroot;
char *app;
char *app_qs;
size_t ini_size;
int dump_config;
char *server_software;
@@ -49,6 +51,8 @@ struct uwsgi_option uwsgi_php_options[] = {
{"php-allowed-script", required_argument, 0, "list the allowed php scripts (require absolute path)", uwsgi_opt_add_string_list, &uphp.allowed_scripts, 0},
{"php-server-software", required_argument, 0, "force php SERVER_SOFTWARE", uwsgi_opt_set_str, &uphp.server_software, 0},
{"php-app", required_argument, 0, "force the php file to run at each request", uwsgi_opt_set_str, &uphp.app, 0},
{"php-var", required_argument, 0, "add/overwrite a CGI variable at each request", uwsgi_opt_add_string_list, &uphp.vars, 0},
{"php-app-qs", required_argument, 0, "when in app mode force QUERY_STRING to the specified value + PATH_INFO", uwsgi_opt_set_str, &uphp.app_qs, 0},
{"php-dump-config", no_argument, 0, "dump php config (if modified via --php-set or append options)", uwsgi_opt_true, &uphp.dump_config, 0},
{0, 0, 0, 0, 0, 0, 0},
@@ -285,6 +289,9 @@ static void sapi_uwsgi_register_variables(zval *track_vars_array TSRMLS_DC)
}
php_register_variable_safe("PATH_INFO", wsgi_req->path_info, wsgi_req->path_info_len, track_vars_array TSRMLS_CC);
if (wsgi_req->query_string_len > 0) {
php_register_variable_safe("QUERY_STRING", wsgi_req->query_string, wsgi_req->query_string_len, track_vars_array TSRMLS_CC);
}
php_register_variable_safe("SCRIPT_NAME", wsgi_req->script_name, wsgi_req->script_name_len, track_vars_array TSRMLS_CC);
php_register_variable_safe("SCRIPT_FILENAME", wsgi_req->file, wsgi_req->file_len, track_vars_array TSRMLS_CC);
@@ -304,6 +311,16 @@ static void sapi_uwsgi_register_variables(zval *track_vars_array TSRMLS_DC)
php_register_variable_safe("PHP_SELF", wsgi_req->script_name, wsgi_req->script_name_len, track_vars_array TSRMLS_CC);
struct uwsgi_string_list *usl = uphp.vars;
while(usl) {
char *equal = strchr(usl->value, '=');
if (equal) {
php_register_variable_safe( estrndup(usl->value, equal-usl->value),
equal+1, strlen(equal+1), track_vars_array TSRMLS_CC);
}
usl = usl->next;
}
}
@@ -658,6 +675,16 @@ int uwsgi_php_init(void) {
uwsgi_log("--- end of PHP custom config ---\n");
}
// fix docroot
if (uphp.docroot) {
char *orig_docroot = uphp.docroot;
uphp.docroot = uwsgi_expand_path(uphp.docroot, strlen(uphp.docroot), NULL);
if (!uphp.docroot) {
uwsgi_log("unable to set php docroot to %s\n", orig_docroot);
exit(1);
}
}
uwsgi_sapi_module.startup(&uwsgi_sapi_module);
// filling http status codes
@@ -766,6 +793,27 @@ int uwsgi_php_request(struct wsgi_request *wsgi_req) {
if (uphp.app) {
strcpy(real_filename, uphp.app);
if (wsgi_req->path_info_len == 1 && wsgi_req->path_info[0] == '/') {
goto appready;
}
if (uphp.app_qs) {
size_t app_qs_len = strlen(uphp.app_qs);
size_t qs_len = wsgi_req->path_info_len + app_qs_len;
if (wsgi_req->query_string_len > 0) {
qs_len += 1 + wsgi_req->query_string_len;
}
char *qs = ecalloc(1, qs_len+1);
memcpy(qs, uphp.app_qs, app_qs_len);
memcpy(qs+app_qs_len, wsgi_req->path_info, wsgi_req->path_info_len);
if (wsgi_req->query_string_len > 0) {
char *ptr = qs+app_qs_len+wsgi_req->path_info_len;
*ptr = '&';
memcpy(ptr+1, wsgi_req->query_string, wsgi_req->query_string_len);
}
wsgi_req->query_string = qs;
wsgi_req->query_string_len = qs_len;
}
appready:
wsgi_req->path_info = "";
wsgi_req->path_info_len = 0;
goto secure2;
@@ -891,7 +939,6 @@ secure2:
secure3:
if (wsgi_req->document_root[wsgi_req->document_root_len-1] == '/') {
wsgi_req->script_name = real_filename + (wsgi_req->document_root_len-1);
}
+1
View File
@@ -51,3 +51,4 @@ int uwsgi_perl_obj_can(SV *, char *, size_t);
int uwsgi_perl_obj_isa(SV *, char *);
int init_psgi_app(struct wsgi_request *, char *, uint16_t, PerlInterpreter **);
PerlInterpreter *uwsgi_perl_new_interpreter(void);
int uwsgi_perl_mule(char *);
+20
View File
@@ -233,6 +233,8 @@ xs_init(pTHX)
/* DynaLoader is a special case */
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
if (!uperl.tmp_input_stash) goto nonworker;
newXS("uwsgi::input::new", XS_input, "uwsgi::input");
newXS("uwsgi::input::read", XS_input_read, "uwsgi::input");
newXS("uwsgi::input::seek", XS_input_seek, "uwsgi::input");
@@ -253,6 +255,8 @@ xs_init(pTHX)
uperl.tmp_streaming_stash[uperl.tmp_current_i] = gv_stashpv("uwsgi::streaming", 0);
nonworker:
#ifdef UWSGI_EMBEDDED
init_perl_embedded_module();
#endif
@@ -496,3 +500,19 @@ void uwsgi_psgi_app() {
}
int uwsgi_perl_mule(char *opt) {
if (uwsgi_endswith(opt, ".pl")) {
PERL_SET_CONTEXT(uperl.main[0]);
uperl.embedding[1] = opt;
if (perl_parse(uperl.main[0], xs_init, 2, uperl.embedding, NULL)) {
return 0;
}
perl_run(uperl.main[0]);
return 1;
}
return 0;
}
+29
View File
@@ -595,6 +595,32 @@ void uwsgi_perl_enable_threads(void) {
#endif
}
int uwsgi_perl_signal_handler(uint8_t sig, void *handler) {
int ret = 0;
dSP;
ENTER;
SAVETMPS;
PUSHMARK(SP);
XPUSHs( sv_2mortal(newSViv(sig)));
PUTBACK;
call_sv( SvRV((SV*)handler), G_DISCARD);
if(SvTRUE(ERRSV)) {
uwsgi_log("[uwsgi-perl error] %s\n", SvPV_nolen(ERRSV));
ret = -1;
}
SPAGAIN;
PUTBACK;
FREETMPS;
LEAVE;
return ret;
}
struct uwsgi_plugin psgi_plugin = {
.name = "psgi",
@@ -606,6 +632,9 @@ struct uwsgi_plugin psgi_plugin = {
.mount_app = uwsgi_perl_mount_app,
.init_thread = uwsgi_perl_init_thread,
.signal_handler = uwsgi_perl_signal_handler,
.mule = uwsgi_perl_mule,
.post_fork = uwsgi_perl_post_fork,
.request = uwsgi_perl_request,
+5
View File
@@ -59,6 +59,11 @@ int psgi_response(struct wsgi_request *wsgi_req, AV *response) {
}
#endif
if (SvTYPE(response) != SVt_PVAV) {
uwsgi_log("invalid PSGI response type\n");
return UWSGI_OK;
}
status_code = av_fetch(response, 0, 0);
if (!status_code) { uwsgi_log("invalid PSGI status code\n"); return UWSGI_OK;}
+51
View File
@@ -1,6 +1,7 @@
#include "psgi.h"
extern struct uwsgi_server uwsgi;
extern struct uwsgi_plugin psgi_plugin;
#ifdef UWSGI_ASYNC
@@ -149,6 +150,27 @@ clear:
}
XS(XS_register_signal) {
dXSARGS;
if (!uwsgi.master_process) {
XSRETURN_NO;
}
psgi_check_args(3);
uint8_t signum = SvIV(ST(0));
STRLEN kindlen;
char *kind = SvPV(ST(1), kindlen);
if (uwsgi_register_signal(signum, kind, (void *) newRV_inc(ST(2)), psgi_plugin.modifier1)) {
XSRETURN_NO;
}
XSRETURN_YES;
}
XS(XS_log) {
dXSARGS;
@@ -219,6 +241,33 @@ XS(XS_suspend) {
XSRETURN_UNDEF;
}
XS(XS_signal_wait) {
dXSARGS;
psgi_check_args(0);
struct wsgi_request *wsgi_req = current_wsgi_req();
int received_signal = -1;
wsgi_req->signal_received = -1;
if (items > 0) {
received_signal = uwsgi_signal_wait(SvIV(ST(0)));
}
else {
received_signal = uwsgi_signal_wait(-1);
}
if (received_signal < 0) {
XSRETURN_NO;
}
wsgi_req->signal_received = received_signal;
XSRETURN_YES;
}
void init_perl_embedded_module() {
psgi_xs(reload);
psgi_xs(cache_set);
@@ -231,5 +280,7 @@ void init_perl_embedded_module() {
psgi_xs(async_connect);
psgi_xs(suspend);
psgi_xs(signal);
psgi_xs(register_signal);
psgi_xs(signal_wait);
}
-1
View File
@@ -67,7 +67,6 @@ void uwsgi_opt_ini_paste(char *opt, char *value, void *foobar) {
struct uwsgi_option uwsgi_python_options[] = {
{"wsgi-file", required_argument, 0, "load .wsgi file", uwsgi_opt_set_str, &up.file_config, 0},
{"wsgi", required_argument, 0, "load .wsgi file", uwsgi_opt_set_str, &up.file_config, 0},
{"file", required_argument, 0, "load .wsgi file", uwsgi_opt_set_str, &up.file_config, 0},
{"eval", required_argument, 0, "eval python code", uwsgi_opt_set_str, &up.eval, 0},
{"module", required_argument,'w', "load a WSGI module", uwsgi_opt_set_str, &up.wsgi_config, 0},
+17 -29
View File
@@ -5,6 +5,8 @@ extern struct uwsgi_server uwsgi;
int uwsgi_routing_func_rewrite(struct wsgi_request *wsgi_req, struct uwsgi_route *ur) {
char *tmp_qs = NULL;
char **subject = (char **) (((char *)(wsgi_req))+ur->subject);
uint16_t *subject_len = (uint16_t *) (((char *)(wsgi_req))+ur->subject_len);
@@ -18,28 +20,26 @@ int uwsgi_routing_func_rewrite(struct wsgi_request *wsgi_req, struct uwsgi_route
path_info_len = query_string - path_info;
query_string++;
query_string_len = strlen(query_string);
if (wsgi_req->query_string_len > 0) {
tmp_qs = uwsgi_concat4n(query_string, query_string_len, "&", 1, wsgi_req->query_string, wsgi_req->query_string_len, "", 0);
query_string = tmp_qs;
query_string_len = strlen(query_string);
}
}
// over engineering, could be requiredin the future...
else {
query_string = "";
if (wsgi_req->query_string_len > 0) {
query_string = wsgi_req->query_string;
query_string_len = wsgi_req->query_string_len;
}
else {
query_string = "";
}
}
char *ptr = uwsgi_req_append(wsgi_req, "PATH_INFO", 9, path_info, path_info_len);
if (!ptr) goto clear;
// fill iovec
if (wsgi_req->var_cnt + 2 >= uwsgi.vec_size - (4 + 1)) {
uwsgi_log("not enough io vectors for rewriting url\n");
goto clear;
}
wsgi_req->hvec[wsgi_req->var_cnt].iov_base = ptr - (2 + 9);
wsgi_req->hvec[wsgi_req->var_cnt].iov_len = 9;
wsgi_req->var_cnt++;
wsgi_req->hvec[wsgi_req->var_cnt].iov_base = ptr;
wsgi_req->hvec[wsgi_req->var_cnt].iov_len = path_info_len;
wsgi_req->var_cnt++;
// set new path_info
wsgi_req->path_info = ptr;
wsgi_req->path_info_len = path_info_len;
@@ -47,31 +47,19 @@ int uwsgi_routing_func_rewrite(struct wsgi_request *wsgi_req, struct uwsgi_route
ptr = uwsgi_req_append(wsgi_req, "QUERY_STRING", 12, query_string, query_string_len);
if (!ptr) goto clear;
// fill iovec
if (wsgi_req->var_cnt + 2 >= uwsgi.vec_size - (4 + 1)) {
uwsgi_log("not enough io vectors for rewriting url\n");
goto clear;
}
wsgi_req->hvec[wsgi_req->var_cnt].iov_base = ptr - (2 + 12);
wsgi_req->hvec[wsgi_req->var_cnt].iov_len = 12;
wsgi_req->var_cnt++;
wsgi_req->hvec[wsgi_req->var_cnt].iov_base = ptr;
wsgi_req->hvec[wsgi_req->var_cnt].iov_len = query_string_len;
wsgi_req->var_cnt++;
// set new query_string
wsgi_req->query_string = ptr;
wsgi_req->query_string_len = query_string_len;
free(path_info);
if (tmp_qs) free(tmp_qs);
if (ur->custom)
return UWSGI_ROUTE_CONTINUE;
return UWSGI_ROUTE_NEXT;
clear:
free(path_info);
if (tmp_qs) free(tmp_qs);
return UWSGI_ROUTE_BREAK;
}
+11
View File
@@ -19,6 +19,14 @@ my $two = sub {
print "two\n";
};
my $four = sub {
my $signum = shift;
print "i am signal ".$signum."\n" ;
};
uwsgi::register_signal(17, '', $four);
uwsgi::register_signal(30, '', $two);
my $three = sub {
my $env = shift;
sleep(1);
@@ -27,6 +35,9 @@ my $three = sub {
my $app = sub {
my $env = shift;
uwsgi::signal(17);
uwsgi::signal(30);
if ($env->{'psgix.cleanup'}) {
print "cleanup supported\n";
push @{$env->{'psgix.cleanup.handlers'}}, $one;
+3 -4
View File
@@ -1529,10 +1529,6 @@ struct uwsgi_server {
int check_static_docroot;
// linked list for offloaded requests
struct uwsgi_offload_request *offload_requests_head;
struct uwsgi_offload_request *offload_requests_tail;
char *daemonize;
char *daemonize2;
int do_not_change_umask;
@@ -3409,6 +3405,9 @@ struct uwsgi_thread {
uint64_t custom1;
uint64_t custom2;
uint64_t custom3;
// linked list for offloaded requests
struct uwsgi_offload_request *offload_requests_head;
struct uwsgi_offload_request *offload_requests_tail;
void (*func)(struct uwsgi_thread *);
};
struct uwsgi_thread *uwsgi_thread_new(void (*)(struct uwsgi_thread *));
+1 -1
View File
@@ -1,6 +1,6 @@
# uWSGI build system
uwsgi_version = '1.4'
uwsgi_version = '1.4.2'
import os
import re