From e0e8bb1932b59993175404bb984ff867370dcdbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Tue, 11 Nov 2014 16:03:00 +0000 Subject: [PATCH] psgi: Don't free the wsgi_req->async_environ atexit, only in request context The atexit hooks can be called outside of the request context. See the discussion at https://github.com/unbit/uwsgi/pull/772 --- plugins/psgi/psgi_plugin.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/plugins/psgi/psgi_plugin.c b/plugins/psgi/psgi_plugin.c index b6dc29cd..93960531 100644 --- a/plugins/psgi/psgi_plugin.c +++ b/plugins/psgi/psgi_plugin.c @@ -708,6 +708,9 @@ 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) { uwsgi_log("*** psgix.harakiri.commit requested ***\n"); @@ -717,9 +720,6 @@ void uwsgi_perl_after_request(struct wsgi_request *wsgi_req) { 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(); @@ -854,7 +854,6 @@ void uwsgi_perl_run_hook(SV *hook) { static void uwsgi_perl_atexit() { int i; - struct wsgi_request *wsgi_req = current_wsgi_req(); if (uwsgi.mywid == 0) goto realstuff; @@ -876,10 +875,6 @@ destroyperl: for(i=0;iasync_environ); - // Destroy the PerlInterpreter, see "perldoc perlembed" perl_destruct(uperl.main[i]); perl_free(uperl.main[i]);