This repository was archived by the owner on Oct 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 369
Fix: Notify app of client disconnection when request is in progress. #1556
Open
gourav-kandoria
wants to merge
2
commits into
nginx:master
Choose a base branch
from
gourav-kandoria:fix_issue_apps_not_notified_when_client_disconnects
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+63
−19
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,8 @@ static int nxt_unit_request_check_response_port(nxt_unit_request_info_t *req, | |
| static int nxt_unit_send_req_headers_ack(nxt_unit_request_info_t *req); | ||
| static int nxt_unit_process_websocket(nxt_unit_ctx_t *ctx, | ||
| nxt_unit_recv_msg_t *recv_msg); | ||
| static int nxt_unit_process_client_error(nxt_unit_ctx_t *ctx, | ||
| nxt_unit_recv_msg_t *recv_msg); | ||
| static int nxt_unit_process_shm_ack(nxt_unit_ctx_t *ctx); | ||
| static nxt_unit_request_info_impl_t *nxt_unit_request_info_get( | ||
| nxt_unit_ctx_t *ctx); | ||
|
|
@@ -1121,6 +1123,10 @@ nxt_unit_process_msg(nxt_unit_ctx_t *ctx, nxt_unit_read_buf_t *rbuf, | |
| rc = nxt_unit_process_websocket(ctx, &recv_msg); | ||
| break; | ||
|
|
||
| case _NXT_PORT_MSG_CLIENT_ERROR: | ||
| rc = nxt_unit_process_client_error(ctx, &recv_msg); | ||
| break; | ||
|
|
||
| case _NXT_PORT_MSG_REMOVE_PID: | ||
|
ac000 marked this conversation as resolved.
|
||
| if (nxt_slow_path(recv_msg.size != sizeof(pid))) { | ||
| nxt_unit_alert(ctx, "#%"PRIu32": remove_pid: invalid message size " | ||
|
|
@@ -1377,18 +1383,16 @@ nxt_unit_process_req_headers(nxt_unit_ctx_t *ctx, nxt_unit_recv_msg_t *recv_msg, | |
|
|
||
| lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); | ||
|
|
||
| res = nxt_unit_request_hash_add(ctx, req); | ||
| if (nxt_slow_path(res != NXT_UNIT_OK)) { | ||
| nxt_unit_req_warn(req, "failed to add request to hash"); | ||
| nxt_unit_request_done(req, NXT_UNIT_ERROR); | ||
| return NXT_UNIT_ERROR; | ||
| } | ||
|
|
||
| if (req->content_length | ||
| > (uint64_t) (req->content_buf->end - req->content_buf->free)) | ||
| { | ||
| res = nxt_unit_request_hash_add(ctx, req); | ||
| if (nxt_slow_path(res != NXT_UNIT_OK)) { | ||
| nxt_unit_req_warn(req, "failed to add request to hash"); | ||
|
|
||
| nxt_unit_request_done(req, NXT_UNIT_ERROR); | ||
|
|
||
| return NXT_UNIT_ERROR; | ||
| } | ||
|
|
||
| /* | ||
| * If application have separate data handler, we may start | ||
| * request processing and process data when it is arrived. | ||
|
|
@@ -1418,7 +1422,7 @@ nxt_unit_process_req_body(nxt_unit_ctx_t *ctx, nxt_unit_recv_msg_t *recv_msg) | |
| nxt_unit_mmap_buf_t *b; | ||
| nxt_unit_request_info_t *req; | ||
|
|
||
| req = nxt_unit_request_hash_find(ctx, recv_msg->stream, recv_msg->last); | ||
| req = nxt_unit_request_hash_find(ctx, recv_msg->stream, 0); | ||
| if (req == NULL) { | ||
| return NXT_UNIT_OK; | ||
| } | ||
|
|
@@ -1722,6 +1726,26 @@ nxt_unit_process_websocket(nxt_unit_ctx_t *ctx, nxt_unit_recv_msg_t *recv_msg) | |
| return NXT_UNIT_OK; | ||
| } | ||
|
|
||
| static int | ||
| nxt_unit_process_client_error(nxt_unit_ctx_t *ctx, nxt_unit_recv_msg_t *recv_msg) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I remember, this line will need wrapping as it just goes over the 80 character limit... |
||
| { | ||
| nxt_unit_impl_t *lib; | ||
| nxt_unit_request_info_t *req; | ||
|
|
||
| req = nxt_unit_request_hash_find(ctx, recv_msg->stream, 0); | ||
|
|
||
| if (req == NULL) { | ||
| return NXT_UNIT_OK; | ||
| } | ||
|
|
||
| lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); | ||
|
|
||
| if (lib->callbacks.close_handler) { | ||
|
ac000 marked this conversation as resolved.
|
||
| lib->callbacks.close_handler(req); | ||
| } | ||
|
|
||
| return NXT_UNIT_OK; | ||
| } | ||
|
|
||
| static int | ||
| nxt_unit_process_shm_ack(nxt_unit_ctx_t *ctx) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.