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

Bug Fix - MiniSSL::Socket#write - use data.byteslice(wrote..-1) #2543

Merged
merged 1 commit into from Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions History.md
@@ -1,3 +1,8 @@
## 5.2.1 / 2021-01-

* Bugfixes
* MiniSSL::Socket#write - use data.byteslice(wrote..-1) ([#2543])

## 5.2.0 / 2021-01-27

* Features
Expand Down
2 changes: 1 addition & 1 deletion lib/puma/minissl.rb
Expand Up @@ -133,7 +133,7 @@ def write(data)

return data_size if need == 0

data = data[wrote..-1]
data = data.byteslice(wrote..-1)
Copy link
Member

Choose a reason for hiding this comment

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

@MSP-Greg Do you understand why 5.1.1 doesn't seem to have the problem stated in #2542? This line of code wasn't changed in #2519 (but surrounding code was: https://github.com/puma/puma/pull/2519/files#diff-5f9e58f45420759185f3cff5203a523482b915cc3e331bb0f060977c2078d903)

Copy link
Member Author

Choose a reason for hiding this comment

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

I will look at 5.1.1 and 5.2.0. I believe the bug requires a response with multi-byte characters, longer than 16kB, and ssl. And, since some html parsers can be rather forgiving...

Copy link
Member

Choose a reason for hiding this comment

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

If I'm reading the code right, I think the bug was in changing line 133 from data.bytesize to data, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Confused. Do you mean changing data.bytesize to data_size, which is set to the value of data.bytesize?

Anyway, I'm working thru it. The code in 5.1.1 was writing 512 byte chunks to the TCPSocket, which seemed not optimized. But, it also appears that it wrote all the data with @engine.write, where the current code is writing it in 16kB chunks. Because 5.1.1 was writing everything with @engine.write, maybe the issues with how it was looping weren't apparent?

Trying to figure out why the difference in write size is happening... Regardless, I believe the current code is a lot faster?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had to review the code changes in minissl.c, but I now recall. It's involved, but I'll write it up.

end
end

Expand Down