]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Maintenance: Removed deprecated Client::replyBodySpace() (#2060)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Sun, 18 May 2025 21:24:18 +0000 (21:24 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Mon, 19 May 2025 14:25:15 +0000 (14:25 +0000)
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.

src/clients/Client.cc
src/clients/Client.h
src/clients/FtpClient.cc

index fa48b6532e533a8dc6f8025daae7aed513e874cf..6ad8dead8df1ed65791ad330484f0f4b6760273e 100644 (file)
@@ -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;
-}
-
index 8c8147f4343fe76c7e2130b36f41b0b891940eca..edd149c42c922f1526b55572f3857671614e1946 100644 (file)
@@ -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;
 
index a667cd5df89f72a4fa924407fd2dc0594efefefa..444426eccaf07b1470836860311f9043448e4f93 100644 (file)
@@ -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");