Skip to content

Check for connection being dead before reuse. - #5893

Closed
cgpe-a wants to merge 1 commit into
curl:masterfrom
cgpe-a:dont-reuse-closed-conn
Closed

cgpe-a wants to merge 1 commit into
curl:masterfrom
cgpe-a:dont-reuse-closed-conn

Conversation

@cgpe-a

@cgpe-a cgpe-a commented Aug 29, 2020

Copy link
Copy Markdown
Contributor

Prevents incorrect reuse of an HTTP connection that has been prematurely shutdown() by the server.

Partial revert of 755083d
conn_maxage: move the check to prune_dead_connections()

Fixes #5884

Note that although this fixes the issue for me, I haven't considered it in the context of the original commit that it partially reverts.

Prevents incorrect reuse of an HTTP connection that has been prematurely shutdown() by the server.

Partial revert of 755083d
    conn_maxage: move the check to prune_dead_connections()
Comment thread lib/url.c

if(extract_if_dead(check, data)) {
/* disconnect it */
(void)Curl_disconnect(data, check, /* dead_connection */TRUE);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: Space after the comment

Comment thread lib/url.c

if(extract_if_dead(check, data)) {
/* disconnect it */
(void)Curl_disconnect(data, check, /* dead_connection */TRUE);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why the cast?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It was there already. We (void) cast at times when we want to emphasize that we know the function returns an error code but we willfully ignore that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also some compilers and code tools may warn if a function result is ignored unless you explicitly (void) it.

@bagder

bagder commented Aug 29, 2020

Copy link
Copy Markdown
Member

I think the problem with the code move in 755083d was that it was made for the conn_maxage logic but then wrongly also moved the check for the regular reuse case. I think this looks like a good change.

@bagder bagder self-assigned this Aug 29, 2020
@bagder

bagder commented Aug 30, 2020

Copy link
Copy Markdown
Member

Thanks!

@bagder bagder closed this in 728f8d3 Aug 30, 2020
@cgpe-a
cgpe-a deleted the dont-reuse-closed-conn branch August 31, 2020 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Connection reused after premature HTTP server close

4 participants