-
Notifications
You must be signed in to change notification settings - Fork 103
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
Conversation
There was a problem hiding this 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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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); |
tempesta_fw/http_msg.c
Outdated
@@ -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); |
There was a problem hiding this comment.
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.
See explanation in #959 (comment).