summaryrefslogtreecommitdiffhomepage
path: root/src/go/unit/nxt_go_port.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-12-27 17:46:17 +0300
committerMax Romanov <max.romanov@nginx.com>2017-12-27 17:46:17 +0300
commit89c0f7c5db5003b8fd8df3e1babb0c802004bf4c (patch)
tree7ac164d6fe41fd76beb3d328e6fde4020f744b63 /src/go/unit/nxt_go_port.c
parent45d08d5145c63fd788f85d9e789314dcf093c99e (diff)
downloadunit-89c0f7c5db5003b8fd8df3e1babb0c802004bf4c.tar.gz
unit-89c0f7c5db5003b8fd8df3e1babb0c802004bf4c.tar.bz2
Implementing the ability to cancel request before worker starts processing it.
Diffstat (limited to 'src/go/unit/nxt_go_port.c')
-rw-r--r--src/go/unit/nxt_go_port.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/go/unit/nxt_go_port.c b/src/go/unit/nxt_go_port.c
index cbf12ab2..f2f1fc5a 100644
--- a/src/go/unit/nxt_go_port.c
+++ b/src/go/unit/nxt_go_port.c
@@ -29,10 +29,18 @@ nxt_go_data_handler(nxt_port_msg_t *port_msg, size_t size)
ctx = malloc(sizeof(nxt_go_run_ctx_t) + size);
- memcpy(ctx + 1, port_msg, size);
- port_msg = (nxt_port_msg_t *) (ctx + 1);
+ memcpy(ctx->port_msg, port_msg, size);
+ port_msg = ctx->port_msg;
- nxt_go_ctx_init(ctx, port_msg, size - sizeof(nxt_port_msg_t));
+ size -= sizeof(nxt_port_msg_t);
+
+ nxt_go_ctx_init(ctx, port_msg, size);
+
+ if (nxt_slow_path(ctx->cancelled)) {
+ nxt_go_debug("request already cancelled by router");
+ free(ctx);
+ return 0;
+ }
r = (nxt_go_request_t)(ctx);
h = &ctx->request.header;