Skip to content

Commit

Permalink
Optimization: Do not zero-terminate Server::inBuf (#1889)
Browse files Browse the repository at this point in the history
... when storing unencoded request body bytes in ConnStateData::bodyPipe

Calling SBuf::c_str() is unnecessary in this context because
BodyPipe::append() does not need/expect a zero-terminated buffer. The
call is relatively expensive when the previous Comm::ReadNow() was able
to fill the entire inBuf trailing space, which is a common occurrence
because Server::maybeMakeSpaceAvailable() uses CLIENT_REQ_BUF_SZ as
idealSpace size, and CLIENT_REQ_BUF_SZ is hard-coded to just 4096 bytes.

The call was added in 2014 commit e728762 that converted inBuf to SBuf.
  • Loading branch information
rousskov authored and squid-anubis committed Aug 21, 2024
1 parent ebbcff2 commit 46b1009
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/client_side.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@ ConnStateData::handleRequestBodyData()
}
} else { // identity encoding
debugs(33,5, "handling plain request body for " << clientConnection);
const size_t putSize = bodyPipe->putMoreData(inBuf.c_str(), inBuf.length());
const auto putSize = bodyPipe->putMoreData(inBuf.rawContent(), inBuf.length());
if (putSize > 0)
consumeInput(putSize);

Expand Down

0 comments on commit 46b1009

Please sign in to comment.