Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix releasing of requests and responses on client disconnects #969

Merged
merged 6 commits into from
Mar 20, 2018

Conversation

vankoven
Copy link
Contributor

See explanation in #959 (comment).

Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only minor changes are required, but, having close release in mind, it'd be good to see on them again.

@@ -1803,6 +1801,14 @@ tfw_http_conn_cli_drop(TfwCliConn *cli_conn)
list_for_each_entry_safe(req, tmp, seq_queue, msg.seq_list) {
req->flags |= TFW_HTTP_F_REQ_DROP;
list_del_init(&req->msg.seq_list);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we should move list_del_init() from tfw_http_resp_pair_free() to the loop in __tfw_http_resp_fwd() while all other calls of tfw_http_resp_pair_free() are either of two cases of using the function: the call after list_del_init() and full list removal.

*/
if (req->resp && (req->resp->flags & TFW_HTTP_F_RESP_READY)) {
tfw_http_resp_pair_free(req);
TFW_INC_STAT_BH(serv.msgs_otherr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is a server error? It seems that a server successfully respond to the request and we're here just because the client drops the connection?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is output of performance statistics before the fix:

. . .
Server messages received		: 20
Server messages forwarded		: 16
Server messages parsing errors		: 0
Server messages filtered out		: 0
Server messages other errors		: 3
. . .

In this stats we see, that one response have disappeared (received != forwarded + p_errors + filtered + o_errors). Other errors is the most suitable counter, which is used for the same situation in other places in code, e.g.

tempesta/tempesta_fw/http.c

Lines 2209 to 2214 in 43e35e9

TFW_DBG2("%s: The client was disconnected, drop resp and req: "
"conn=[%p]\n",
__func__, cli_conn);
ss_close_sync(cli_conn->sk, true);
tfw_http_resp_pair_free(req);
TFW_INC_STAT_BH(serv.msgs_otherr);

@@ -948,6 +948,9 @@ tfw_http_msg_free(TfwHttpMsg *m)
if (!m)
return;

/* Check that the paired response was destroyed before request. */
if (m->conn && (TFW_CONN_TYPE(m->conn) & Conn_Clnt))
WARN_ON_ONCE(m->pair);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we don't write assertions this way, but place the whole condition into the assertion.

@vankoven vankoven merged commit d6f21da into master Mar 20, 2018
@vankoven vankoven deleted the ik-fix-pending-for-srv-issue branch March 20, 2018 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants