From: Eduard Bagdasaryan Date: Sun, 18 May 2025 21:24:18 +0000 (+0000) Subject: Maintenance: Removed deprecated Client::replyBodySpace() (#2060) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d9a9960423a7976a2887ca8a39d846d31e38a3cf;p=thirdparty%2Fsquid.git Maintenance: Removed deprecated Client::replyBodySpace() (#2060) Except for a trivial spaceSize() call and a never-executed (for the only caller) `space` parameter adjustment, replyBodySpace() duplicates Client::calcBufferSpaceToReserve(). This duplication complicates refactoring aimed at addressing other known buffer management problems. --- diff --git a/src/clients/Client.cc b/src/clients/Client.cc index fa48b6532e..6ad8dead8d 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 8c8147f434..edd149c42c 100644 --- a/src/clients/Client.h +++ b/src/clients/Client.h @@ -160,8 +160,6 @@ protected: 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 a667cd5df8..444426ecca 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");