summaryrefslogtreecommitdiffhomepage
path: root/src/python/nxt_python_asgi.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2020-11-18 22:33:53 +0300
committerMax Romanov <max.romanov@nginx.com>2020-11-18 22:33:53 +0300
commit6c3c83561a97b91f18a771e0c582c5ed4013a9a6 (patch)
tree32ebaf18f1ea9efdac9fc2b32eb5f7d49727d603 /src/python/nxt_python_asgi.c
parent300347a5cffa4187921384bdd02c5bb90875f9e5 (diff)
downloadunit-6c3c83561a97b91f18a771e0c582c5ed4013a9a6.tar.gz
unit-6c3c83561a97b91f18a771e0c582c5ed4013a9a6.tar.bz2
Libunit: closing active requests on quit.
Diffstat (limited to 'src/python/nxt_python_asgi.c')
-rw-r--r--src/python/nxt_python_asgi.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/python/nxt_python_asgi.c b/src/python/nxt_python_asgi.c
index e11a3b6c..98aeedf4 100644
--- a/src/python/nxt_python_asgi.c
+++ b/src/python/nxt_python_asgi.c
@@ -25,6 +25,7 @@ static int nxt_python_asgi_run(nxt_unit_ctx_t *ctx);
static void nxt_py_asgi_remove_reader(nxt_unit_ctx_t *ctx,
nxt_unit_port_t *port);
static void nxt_py_asgi_request_handler(nxt_unit_request_info_t *req);
+static void nxt_py_asgi_close_handler(nxt_unit_request_info_t *req);
static PyObject *nxt_py_asgi_create_http_scope(nxt_unit_request_info_t *req);
static PyObject *nxt_py_asgi_create_address(nxt_unit_sptr_t *sptr, uint8_t len,
@@ -179,7 +180,7 @@ nxt_python_asgi_init(nxt_unit_init_t *init, nxt_python_proto_t *proto)
init->callbacks.request_handler = nxt_py_asgi_request_handler;
init->callbacks.data_handler = nxt_py_asgi_http_data_handler;
init->callbacks.websocket_handler = nxt_py_asgi_websocket_handler;
- init->callbacks.close_handler = nxt_py_asgi_websocket_close_handler;
+ init->callbacks.close_handler = nxt_py_asgi_close_handler;
init->callbacks.quit = nxt_py_asgi_quit;
init->callbacks.shm_ack_handler = nxt_py_asgi_shm_ack_handler;
init->callbacks.add_port = nxt_py_asgi_add_port;
@@ -551,6 +552,18 @@ release_asgi:
}
+static void
+nxt_py_asgi_close_handler(nxt_unit_request_info_t *req)
+{
+ if (req->request->websocket_handshake) {
+ nxt_py_asgi_websocket_close_handler(req);
+
+ } else {
+ nxt_py_asgi_http_close_handler(req);
+ }
+}
+
+
static PyObject *
nxt_py_asgi_create_http_scope(nxt_unit_request_info_t *req)
{