-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround asio::ssl async_read_some busy-loop
chriskohlhoff/asio#1015 `asio::ssl` has a bug where calling async_read_some with `null_buffers` isn't correctly handled, and more or less immediately invokes the provided handler with no data. This causes `amqpprox` to busy-loop whenever a TLS socket has been accepted or opened. There were two options for how to fix this: 1) Always read with a fixed size buffer, such as 32kb. This would simplify the code slightly, at the expense of needing multiple reads to handle larger than 32kb frames in non-TLS mode, even when the full frame is available to `amqpprox` in one go. 2) Ask asio::ssl to read with a very small buffer, then ask the openssl library how many bytes are available. This technique aligns with how `amqpprox`'s read loop works today. That is what is implemented here. In theory something similar could be upstreamed into `asio::ssl`. It's a little tricky though and this exact code couldn't handle the generic `MutableBufferSequence` interface - we can take some shortcuts in our code. I've done some benchmarking to check this change isn't going to regress performance noticeably. Data throughput tests indicate that this fix improves performance for TLS connections over the existing code. Still running connection throughput tests.
- Loading branch information
1 parent
c8bb8d2
commit 4081d1c
Showing
2 changed files
with
108 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters