mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-05 21:21:53 +00:00
fixes for non ithreads perl
This commit is contained in:
@@ -237,8 +237,7 @@ PerlInterpreter *uwsgi_perl_new_interpreter(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dTHXa(pi);
|
||||
PERL_SET_CONTEXT(pi);
|
||||
PERL_SET_CONTEXT(pi);
|
||||
|
||||
PL_perl_destruct_level = 2;
|
||||
PL_origalen = 1;
|
||||
@@ -249,10 +248,6 @@ PerlInterpreter *uwsgi_perl_new_interpreter(void) {
|
||||
return pi;
|
||||
}
|
||||
|
||||
void uwsgi_perl_set_context(PerlInterpreter *interpreter) {
|
||||
dTHXa(interpreter);
|
||||
PERL_SET_CONTEXT(interpreter);
|
||||
}
|
||||
|
||||
int init_psgi_app(struct wsgi_request *wsgi_req, char *app, uint16_t app_len, PerlInterpreter **interpreters) {
|
||||
|
||||
@@ -335,7 +330,7 @@ int init_psgi_app(struct wsgi_request *wsgi_req, char *app, uint16_t app_len, Pe
|
||||
}
|
||||
}
|
||||
|
||||
uwsgi_perl_set_context(interpreters[i]);
|
||||
PERL_SET_CONTEXT(interpreters[i]);
|
||||
|
||||
uperl.tmp_current_i = i;
|
||||
|
||||
@@ -358,7 +353,7 @@ int init_psgi_app(struct wsgi_request *wsgi_req, char *app, uint16_t app_len, Pe
|
||||
exit(1);
|
||||
}
|
||||
|
||||
uwsgi_perl_set_context(interpreters[0]);
|
||||
PERL_SET_CONTEXT(interpreters[0]);
|
||||
}
|
||||
|
||||
free(buf);
|
||||
@@ -399,7 +394,6 @@ int init_psgi_app(struct wsgi_request *wsgi_req, char *app, uint16_t app_len, Pe
|
||||
|
||||
// restore context if required
|
||||
if (interpreters != uperl.main) {
|
||||
dTHXa(uperl.main[0]);
|
||||
PERL_SET_CONTEXT(uperl.main[0]);
|
||||
}
|
||||
|
||||
@@ -415,7 +409,6 @@ clear:
|
||||
free(interpreters);
|
||||
}
|
||||
|
||||
dTHXa(uperl.main[0]);
|
||||
PERL_SET_CONTEXT(uperl.main[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
+20
-15
@@ -22,8 +22,7 @@ extern struct http_status_codes hsc[];
|
||||
SV *uwsgi_perl_obj_new(char *class, size_t class_len) {
|
||||
|
||||
SV *newobj;
|
||||
// set current context ?
|
||||
dTHX;
|
||||
|
||||
dSP;
|
||||
|
||||
ENTER;
|
||||
@@ -50,10 +49,8 @@ SV *uwsgi_perl_call_stream(SV *func) {
|
||||
SV *ret = NULL;
|
||||
struct wsgi_request *wsgi_req = current_wsgi_req();
|
||||
struct uwsgi_app *wi = &uwsgi_apps[wsgi_req->app_id];
|
||||
// set current context ?
|
||||
dTHX;
|
||||
dSP;
|
||||
|
||||
dSP;
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
PUSHMARK(SP);
|
||||
@@ -80,8 +77,7 @@ SV *uwsgi_perl_call_stream(SV *func) {
|
||||
int uwsgi_perl_obj_can(SV *obj, char *method, size_t len) {
|
||||
|
||||
int ret;
|
||||
// set current context ? needed for threading
|
||||
dTHX;
|
||||
|
||||
dSP;
|
||||
|
||||
ENTER;
|
||||
@@ -109,7 +105,6 @@ SV *uwsgi_perl_obj_call(SV *obj, char *method) {
|
||||
|
||||
SV *ret = NULL;
|
||||
|
||||
dTHX;
|
||||
dSP;
|
||||
|
||||
ENTER;
|
||||
@@ -143,7 +138,6 @@ AV *psgi_call(struct wsgi_request *wsgi_req, SV *psgi_func, SV *env) {
|
||||
|
||||
AV *ret = NULL;
|
||||
|
||||
dTHX;
|
||||
dSP;
|
||||
|
||||
ENTER;
|
||||
@@ -292,6 +286,13 @@ int uwsgi_perl_init(){
|
||||
uperl.embedding[1] = "-e";
|
||||
uperl.embedding[2] = "0";
|
||||
|
||||
#ifndef USE_ITHREADS
|
||||
if (uwsgi.threads > 1) {
|
||||
uwsgi_log("your Perl environment does not support threads\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (setenv("PLACK_ENV", "uwsgi", 0)) {
|
||||
uwsgi_error("setenv()");
|
||||
}
|
||||
@@ -320,6 +321,8 @@ int uwsgi_perl_init(){
|
||||
}
|
||||
}
|
||||
|
||||
PERL_SET_CONTEXT(uperl.main[0]);
|
||||
|
||||
// filling http status codes
|
||||
for (http_sc = hsc; http_sc->message != NULL; http_sc++) {
|
||||
http_sc->message_size = strlen(http_sc->message);
|
||||
@@ -377,7 +380,6 @@ int uwsgi_perl_request(struct wsgi_request *wsgi_req) {
|
||||
wi->requests++;
|
||||
|
||||
if (((PerlInterpreter **)wi->interpreter)[wsgi_req->async_id] != uperl.main[wsgi_req->async_id]) {
|
||||
dTHXa(((PerlInterpreter **)wi->interpreter)[wsgi_req->async_id]);
|
||||
PERL_SET_CONTEXT(((PerlInterpreter **)wi->interpreter)[wsgi_req->async_id]);
|
||||
}
|
||||
|
||||
@@ -427,7 +429,6 @@ clear:
|
||||
|
||||
// restore main interpreter if needed
|
||||
if (((PerlInterpreter **)wi->interpreter)[wsgi_req->async_id] != uperl.main[wsgi_req->async_id]) {
|
||||
dTHXa(uperl.main[wsgi_req->async_id]);
|
||||
PERL_SET_CONTEXT(uperl.main[wsgi_req->async_id]);
|
||||
}
|
||||
|
||||
@@ -481,17 +482,21 @@ void uwsgi_perl_post_fork() {
|
||||
|
||||
int uwsgi_perl_mount_app(char *mountpoint, char *app, int regexp) {
|
||||
|
||||
uwsgi.wsgi_req->appid = mountpoint;
|
||||
uwsgi.wsgi_req->appid_len = strlen(mountpoint);
|
||||
if (uwsgi_endswith(app, ".pl") || uwsgi_endswith(app, ".psgi")) {
|
||||
uwsgi.wsgi_req->appid = mountpoint;
|
||||
uwsgi.wsgi_req->appid_len = strlen(mountpoint);
|
||||
|
||||
return init_psgi_app(uwsgi.wsgi_req, app, strlen(app), NULL);
|
||||
return init_psgi_app(uwsgi.wsgi_req, app, strlen(app), NULL);
|
||||
}
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
void uwsgi_perl_init_thread(int core_id) {
|
||||
|
||||
dTHXa(uperl.main[core_id]);
|
||||
#ifdef USE_ITHREADS
|
||||
PERL_SET_CONTEXT(uperl.main[core_id]);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct uwsgi_plugin psgi_plugin = {
|
||||
|
||||
@@ -812,12 +812,14 @@ int uwsgi_python_magic(char *mountpoint, char *lazy) {
|
||||
int uwsgi_python_mount_app(char *mountpoint, char *app, int regexp) {
|
||||
|
||||
int id;
|
||||
uwsgi.wsgi_req->appid = mountpoint;
|
||||
uwsgi.wsgi_req->appid_len = strlen(mountpoint);
|
||||
if (uwsgi.single_interpreter) {
|
||||
id = init_uwsgi_app(LOADER_MOUNT, app, uwsgi.wsgi_req, up.main_thread, PYTHON_APP_TYPE_WSGI);
|
||||
}
|
||||
id = init_uwsgi_app(LOADER_MOUNT, app, uwsgi.wsgi_req, NULL, PYTHON_APP_TYPE_WSGI);
|
||||
|
||||
if (strchr(app, ':') || uwsgi_endswith(app, ".py") || uwsgi_endswith(app, ".wsgi")) {
|
||||
uwsgi.wsgi_req->appid = mountpoint;
|
||||
uwsgi.wsgi_req->appid_len = strlen(mountpoint);
|
||||
if (uwsgi.single_interpreter) {
|
||||
id = init_uwsgi_app(LOADER_MOUNT, app, uwsgi.wsgi_req, up.main_thread, PYTHON_APP_TYPE_WSGI);
|
||||
}
|
||||
id = init_uwsgi_app(LOADER_MOUNT, app, uwsgi.wsgi_req, NULL, PYTHON_APP_TYPE_WSGI);
|
||||
|
||||
#ifdef UWSGI_PCRE
|
||||
int i;
|
||||
@@ -833,7 +835,9 @@ int uwsgi_python_mount_app(char *mountpoint, char *app, int regexp) {
|
||||
}
|
||||
#endif
|
||||
|
||||
return id;
|
||||
return id;
|
||||
}
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -564,14 +564,19 @@ int uwsgi_parse_vars(struct wsgi_request *wsgi_req) {
|
||||
|
||||
/* set an HTTP 500 status as default */
|
||||
wsgi_req->status = 500;
|
||||
|
||||
|
||||
// skip if already parsed
|
||||
if (wsgi_req->parsed) return 0;
|
||||
|
||||
// has the protocol already parsed the request ?
|
||||
if (wsgi_req->uri_len > 0) {
|
||||
wsgi_req->parsed = 1;
|
||||
i = uwsgi_simple_parse_vars(wsgi_req, ptrbuf, bufferend);
|
||||
if (i == 0) goto next;
|
||||
return i;
|
||||
}
|
||||
|
||||
wsgi_req->parsed = 1;
|
||||
wsgi_req->path_info_pos = -1;
|
||||
|
||||
while (ptrbuf < bufferend) {
|
||||
|
||||
Reference in New Issue
Block a user