summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_python_wsgi.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2018-03-15 17:10:24 +0300
committerValentin Bartenev <vbart@nginx.com>2018-03-15 17:10:24 +0300
commitcf2767625fa164b813ef489795e9eebc11536475 (patch)
tree88e2df9d6cc055101a3e199f221a4de7b72f4825 /src/nxt_python_wsgi.c
parent6da1207d952ec903d09bc793cb18f1f3834e6d1b (diff)
downloadunit-cf2767625fa164b813ef489795e9eebc11536475.tar.gz
unit-cf2767625fa164b813ef489795e9eebc11536475.tar.bz2
Python: fixed crash if start_response() is called inside iteration.
The start_response() uses nxt_python_run_ctx, but it was unset right after the application call.
Diffstat (limited to '')
-rw-r--r--src/nxt_python_wsgi.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nxt_python_wsgi.c b/src/nxt_python_wsgi.c
index 15947fa0..d2eb5d5b 100644
--- a/src/nxt_python_wsgi.c
+++ b/src/nxt_python_wsgi.c
@@ -353,19 +353,17 @@ nxt_python_run(nxt_task_t *task, nxt_app_rmsg_t *rmsg, nxt_app_wmsg_t *wmsg)
return NXT_ERROR;
}
- nxt_python_run_ctx = &run_ctx;
-
PyTuple_SET_ITEM(args, 0, environ);
Py_INCREF(nxt_py_start_resp_obj);
PyTuple_SET_ITEM(args, 1, nxt_py_start_resp_obj);
+ nxt_python_run_ctx = &run_ctx;
+
result = PyObject_CallObject(nxt_py_application, args);
Py_DECREF(args);
- nxt_python_run_ctx = NULL;
-
if (nxt_slow_path(result == NULL)) {
nxt_log_error(NXT_LOG_ERR, task->log,
"Python failed to call the application");
@@ -428,6 +426,7 @@ nxt_python_run(nxt_task_t *task, nxt_app_rmsg_t *rmsg, nxt_app_wmsg_t *wmsg)
}
Py_DECREF(result);
+ nxt_python_run_ctx = NULL;
return NXT_OK;
@@ -446,6 +445,7 @@ fail:
}
Py_DECREF(result);
+ nxt_python_run_ctx = NULL;
return NXT_ERROR;
}