zwoop commented on code in PR #13202:
URL: https://github.com/apache/trafficserver/pull/13202#discussion_r3360437009
##########
src/iocore/net/SSLNetVConnection.cc:
##########
@@ -737,18 +737,19 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite,
MIOBufferAccessor &buf
Dbg(dbg_ctl_ssl, "towrite=%" PRId64, towrite);
+ // Per-thread scratch to coalesce fragmented blocks into one SSL_write.
Reuse across
+ // connections is safe: a WANT_WRITE retry flushes SSL's own record buffer,
not this.
+ static thread_local char gather_buf[SSL_MAX_TLS_RECORD_SIZE];
+
ERR_clear_error();
do {
- // What is remaining left in the next block?
- l = buf.reader()->block_read_avail();
- char *current_block = buf.reader()->start();
+ IOBufferReader *reader = buf.reader();
- // check if to amount to write exceeds that in this buffer
+ // Unlike the per-block original, l may span blocks so it can be coalesced
below.
+ int64_t avail = reader->read_avail();
int64_t wavail = towrite - total_written;
- if (l > wavail) {
- l = wavail;
- }
+ l = (wavail < avail) ? wavail : avail;
Review Comment:
Good catch — fixed. `towrite` is already bounded by `read_avail()` in the
caller (write_to_net_io), so the per-iteration `read_avail()` walk was
redundant; now using `towrite - total_written` directly with no O(n)
block-chain walk.
##########
src/iocore/net/SSLNetVConnection.cc:
##########
@@ -737,18 +737,19 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite,
MIOBufferAccessor &buf
Dbg(dbg_ctl_ssl, "towrite=%" PRId64, towrite);
+ // Per-thread scratch to coalesce fragmented blocks into one SSL_write.
Reuse across
+ // connections is safe: a WANT_WRITE retry flushes SSL's own record buffer,
not this.
+ static thread_local char gather_buf[SSL_MAX_TLS_RECORD_SIZE];
Review Comment:
Updated the PR description to match the implementation — this is a userspace
staging-buffer gather (coalesce plaintext, one SSL_write per chunk), not the
buffer-BIO approach the original description described.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]