Skip to content

Commit d972d24

Browse files
eduard-bagdasaryansquid-anubis
authored andcommitted
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.
1 parent 1723d15 commit d972d24

3 files changed

Lines changed: 3 additions & 44 deletions

File tree

src/clients/Client.cc

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,44 +1110,3 @@ Client::calcBufferSpaceToReserve(size_t space, const size_t wantSpace) const
11101110
return space;
11111111
}
11121112

1113-
size_t
1114-
Client::replyBodySpace(const MemBuf &readBuf, const size_t minSpace) const
1115-
{
1116-
size_t space = readBuf.spaceSize(); // available space w/o heroic measures
1117-
if (space < minSpace) {
1118-
const size_t maxSpace = readBuf.potentialSpaceSize(); // absolute best
1119-
space = min(minSpace, maxSpace); // do not promise more than asked
1120-
}
1121-
1122-
#if USE_ADAPTATION
1123-
if (responseBodyBuffer) {
1124-
return 0; // Stop reading if already overflowed waiting for ICAP to catch up
1125-
}
1126-
1127-
if (virginBodyDestination != nullptr) {
1128-
/*
1129-
* BodyPipe buffer has a finite size limit. We
1130-
* should not read more data from the network than will fit
1131-
* into the pipe buffer or we _lose_ what did not fit if
1132-
* the response ends sooner that BodyPipe frees up space:
1133-
* There is no code to keep pumping data into the pipe once
1134-
* response ends and serverComplete() is called.
1135-
*
1136-
* If the pipe is totally full, don't register the read handler.
1137-
* The BodyPipe will call our noteMoreBodySpaceAvailable() method
1138-
* when it has free space again.
1139-
*/
1140-
size_t adaptation_space =
1141-
virginBodyDestination->buf().potentialSpaceSize();
1142-
1143-
debugs(11,9, "Client may read up to min(" <<
1144-
adaptation_space << ", " << space << ") bytes");
1145-
1146-
if (adaptation_space < space)
1147-
space = adaptation_space;
1148-
}
1149-
#endif
1150-
1151-
return space;
1152-
}
1153-

src/clients/Client.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ class Client:
160160
void adaptOrFinalizeReply();
161161
void addVirginReplyBody(const char *buf, ssize_t len);
162162
void storeReplyBody(const char *buf, ssize_t len);
163-
/// \deprecated use SBuf I/O API and calcBufferSpaceToReserve() instead
164-
size_t replyBodySpace(const MemBuf &readBuf, const size_t minSpace) const;
165163
/// determine how much space the buffer needs to reserve
166164
size_t calcBufferSpaceToReserve(const size_t space, const size_t wantSpace) const;
167165

src/clients/FtpClient.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,9 @@ Ftp::Client::maybeReadVirginBody()
925925

926926
initReadBuf();
927927

928-
const int read_sz = replyBodySpace(*data.readBuf, 0);
928+
// XXX: We only use this call to decide whether to read; we never increase data.readBuf space.
929+
// TODO: Upgrade data.readBuf to SBuf and merge this with similar HttpStateData::readReply() code.
930+
const auto read_sz = calcBufferSpaceToReserve(data.readBuf->spaceSize(), data.readBuf->spaceSize());
929931

930932
debugs(9, 9, "FTP may read up to " << read_sz << " bytes");
931933

0 commit comments

Comments
 (0)