tiny fixes in the psgi plugin

This commit is contained in:
Roberto De Ioris
2013-01-20 17:06:29 +01:00
parent 77bd73d597
commit 215e514385
3 changed files with 15 additions and 11 deletions
+4 -3
View File
@@ -430,6 +430,7 @@ int uwsgi_perl_request(struct wsgi_request *wsgi_req) {
struct uwsgi_app *wi = &uwsgi_apps[wsgi_req->app_id];
wi->requests++;
if (uwsgi.threads < 2) {
if (((PerlInterpreter **)wi->interpreter)[0] != uperl.main[0]) {
PERL_SET_CONTEXT(((PerlInterpreter **)wi->interpreter)[0]);
@@ -447,6 +448,7 @@ int uwsgi_perl_request(struct wsgi_request *wsgi_req) {
wsgi_req->async_environ = build_psgi_env(wsgi_req);
if (!wsgi_req->async_environ) goto clear;
if (uwsgi.threads > 1) {
wsgi_req->async_result = psgi_call(wsgi_req, ((SV **)wi->callable)[wsgi_req->async_id], wsgi_req->async_environ);
}
@@ -635,12 +637,12 @@ int uwsgi_perl_signal_handler(uint8_t sig, void *handler) {
call_sv( SvRV((SV*)handler), G_DISCARD);
SPAGAIN;
if(SvTRUE(ERRSV)) {
uwsgi_log("[uwsgi-perl error] %s", SvPV_nolen(ERRSV));
ret = -1;
}
SPAGAIN;
PUTBACK;
FREETMPS;
LEAVE;
@@ -653,17 +655,16 @@ void uwsgi_perl_run_hook(SV *hook) {
ENTER;
SAVETMPS;
PUSHMARK(SP);
XPUSHs( hook );
PUTBACK;
call_sv( SvRV(hook), G_DISCARD);
SPAGAIN;
if(SvTRUE(ERRSV)) {
uwsgi_log("[uwsgi-perl error] %s", SvPV_nolen(ERRSV));
return;
}
SPAGAIN;
PUTBACK;
FREETMPS;
LEAVE;
+2
View File
@@ -73,6 +73,7 @@ int psgi_response(struct wsgi_request *wsgi_req, AV *response) {
char *status_str = SvPV(*status_code, hlen);
if (uwsgi_response_prepare_headers(wsgi_req, status_str, hlen)) return UWSGI_OK;
hitem = av_fetch(response, 1, 0);
if (!hitem) { uwsgi_log("invalid PSGI headers\n"); return UWSGI_OK;}
@@ -86,6 +87,7 @@ int psgi_response(struct wsgi_request *wsgi_req, AV *response) {
hitem = av_fetch(headers,i+1,0);
chitem2 = SvPV(*hitem, hlen2);
if (uwsgi_response_add_header(wsgi_req, chitem, hlen, chitem2, hlen2)) return UWSGI_OK;
i++;
}
hitem = av_fetch(response, 2, 0);
+9 -8
View File
@@ -33,6 +33,15 @@ my $three = sub {
print "three\n";
};
uwsgi::postfork(sub {
print "forked !!!\n";
});
uwsgi::atexit(sub {
print "exited\n";
});
my $app = sub {
my $env = shift;
uwsgi::signal(17);
@@ -55,11 +64,3 @@ my $app = sub {
[ "Hello World\r\n", $env->{'REQUEST_URI'}, uwsgi::cache_get('key1'), uwsgi::call('hello') ],
];
};
uwsgi::postfork(sub {
print "forked !!!\n";
});
uwsgi::atexit(sub {
print "exited\n";
});