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 #2603: TLS read path #2607

Merged
merged 1 commit into from
Feb 14, 2024
Merged

Fix #2603: TLS read path #2607

merged 1 commit into from
Feb 14, 2024

Conversation

cpq
Copy link
Member

@cpq cpq commented Feb 13, 2024

No description provided.

@cpq cpq requested a review from scaprile February 13, 2024 16:49
Comment on lines -285 to 287
if (n == MG_IO_ERR && mg_tls_pending(c) == 0 && c->rtls.len == 0) {
if (n == MG_IO_ERR && c->rtls.len == 0) {
// Close only if we have fully drained both raw (rtls) and TLS buffers
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we also check for mg_tls_pending() as before ? Otherwise I think the comment is not accurate

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question - but I am unsure about that.
It looks like we might not need mg_tls_pending() at all.
TLS exchanges data by so-called "records", with "record length" specified at the beginning of the "record". so I expect TLS code to retrieve data from c->rtls by records. Meaning, if c->rtls is empty, there could not be anything pending. But that's a theory, that's why I did not remove mg_tls_pending() yet.
I suggest to give it some runway and see.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That seems to be implementation dependent. If it drains the transport buffer until it fills a record, then we need a pending function; if it checks the buffer and then retrieves a whole record, leaving whatever may remain, then we don't.
As this is just for connection closure, not having outstanding data seems a good reason to close anyway.

@scaprile scaprile merged commit 4ab2309 into master Feb 14, 2024
61 of 63 checks passed
@scaprile scaprile deleted the tls branch February 14, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants