This commit is contained in:
Unbit
2014-11-12 07:43:34 +01:00
parent 5d338cfb3a
commit 9d4f4eb3c3
+25 -29
View File
@@ -661,32 +661,18 @@ void uwsgi_perl_after_request(struct wsgi_request *wsgi_req) {
if (SvTRUE(*harakiri)) wsgi_req->async_plagued = 1;
}
// Free the $env hash
SvREFCNT_dec(wsgi_req->async_environ);
// async plagued could be defined in other areas...
if (wsgi_req->async_plagued) {
int i;
uwsgi_log("*** psgix.harakiri.commit requested ***\n");
// clear the env, make sure any DESTROY attached to it will
// run.
SvREFCNT_dec(wsgi_req->async_environ);
// We must free our perl context(s) so any DESTROY hooks
// etc. will run.
for(i=0;i<uwsgi.threads;i++) {
perl_destruct(uperl.main[i]);
perl_free(uperl.main[i]);
}
free(uperl.main);
// This will call simple_goodbye_cruel_world() which'll
// exit(0). So we won't run anything below.
// Before we call exit(0) we'll run the
// uwsgi_perl_atexit() hook which'll properly tear
// down the interpreter.
goodbye_cruel_world();
}
// clear the env
SvREFCNT_dec(wsgi_req->async_environ);
// now we can check for changed files
if (uperl.auto_reload) {
time_t now = uwsgi_now();
@@ -820,24 +806,34 @@ void uwsgi_perl_run_hook(SV *hook) {
}
static void uwsgi_perl_atexit() {
int i;
if (uwsgi.mywid == 0) goto realstuff;
// if hijacked do not run atexit hooks
// if hijacked do not run atexit hooks -- TODO: explain why
// not.
if (uwsgi.workers[uwsgi.mywid].hijacked)
return;
goto destroyperl;
// if busy do not run atexit hooks
if (uwsgi_worker_is_busy(uwsgi.mywid))
return;
// managing atexit in async mode is a real pain...skip it for now
if (uwsgi.async > 1)
return;
realstuff:
if (uperl.atexit) {
uwsgi_perl_run_hook(uperl.atexit);
}
destroyperl:
// We must free our perl context(s) so any DESTROY hooks
// etc. will run.
for(i=0;i<uwsgi.threads;i++) {
PERL_SET_CONTEXT(uperl.main[i]);
// Destroy the PerlInterpreter, see "perldoc perlembed"
perl_destruct(uperl.main[i]);
perl_free(uperl.main[i]);
}
PERL_SYS_TERM();
free(uperl.main);
}
static uint64_t uwsgi_perl_rpc(void *func, uint8_t argc, char **argv, uint16_t argvs[], char **buffer) {