From ff6a778e358cea3005d79d436298c1c10d6e4378 Mon Sep 17 00:00:00 2001 From: Eduard Bagdasaryan Date: Thu, 8 May 2025 15:35:06 +0300 Subject: [PATCH] Removed deprecated Client::replyBodySpace() The deprecated method was basically a duplicate of Client::calcBufferSpaceToReserve(). --- src/clients/Client.cc | 41 ---------------------------------------- src/clients/Client.h | 2 -- src/clients/FtpClient.cc | 4 +++- 3 files changed, 3 insertions(+), 44 deletions(-) diff --git a/src/clients/Client.cc b/src/clients/Client.cc index fa48b6532e5..6ad8dead8df 100644 --- a/src/clients/Client.cc +++ b/src/clients/Client.cc @@ -1110,44 +1110,3 @@ Client::calcBufferSpaceToReserve(size_t space, const size_t wantSpace) const return space; } -size_t -Client::replyBodySpace(const MemBuf &readBuf, const size_t minSpace) const -{ - size_t space = readBuf.spaceSize(); // available space w/o heroic measures - if (space < minSpace) { - const size_t maxSpace = readBuf.potentialSpaceSize(); // absolute best - space = min(minSpace, maxSpace); // do not promise more than asked - } - -#if USE_ADAPTATION - if (responseBodyBuffer) { - return 0; // Stop reading if already overflowed waiting for ICAP to catch up - } - - if (virginBodyDestination != nullptr) { - /* - * BodyPipe buffer has a finite size limit. We - * should not read more data from the network than will fit - * into the pipe buffer or we _lose_ what did not fit if - * the response ends sooner that BodyPipe frees up space: - * There is no code to keep pumping data into the pipe once - * response ends and serverComplete() is called. - * - * If the pipe is totally full, don't register the read handler. - * The BodyPipe will call our noteMoreBodySpaceAvailable() method - * when it has free space again. - */ - size_t adaptation_space = - virginBodyDestination->buf().potentialSpaceSize(); - - debugs(11,9, "Client may read up to min(" << - adaptation_space << ", " << space << ") bytes"); - - if (adaptation_space < space) - space = adaptation_space; - } -#endif - - return space; -} - diff --git a/src/clients/Client.h b/src/clients/Client.h index 8c8147f4343..edd149c42c9 100644 --- a/src/clients/Client.h +++ b/src/clients/Client.h @@ -160,8 +160,6 @@ class Client: void adaptOrFinalizeReply(); void addVirginReplyBody(const char *buf, ssize_t len); void storeReplyBody(const char *buf, ssize_t len); - /// \deprecated use SBuf I/O API and calcBufferSpaceToReserve() instead - size_t replyBodySpace(const MemBuf &readBuf, const size_t minSpace) const; /// determine how much space the buffer needs to reserve size_t calcBufferSpaceToReserve(const size_t space, const size_t wantSpace) const; diff --git a/src/clients/FtpClient.cc b/src/clients/FtpClient.cc index a667cd5df89..444426eccaf 100644 --- a/src/clients/FtpClient.cc +++ b/src/clients/FtpClient.cc @@ -925,7 +925,9 @@ Ftp::Client::maybeReadVirginBody() initReadBuf(); - const int read_sz = replyBodySpace(*data.readBuf, 0); + // XXX: We only use this call to decide whether to read; we never increase data.readBuf space. + // TODO: Upgrade data.readBuf to SBuf and merge this with similar HttpStateData::readReply() code. + const auto read_sz = calcBufferSpaceToReserve(data.readBuf->spaceSize(), data.readBuf->spaceSize()); debugs(9, 9, "FTP may read up to " << read_sz << " bytes");