Skip to content

Maintenance: Removed deprecated Client::replyBodySpace()#2060

Closed
eduard-bagdasaryan wants to merge 2 commits into
squid-cache:masterfrom
measurement-factory:SQUID-1075-remove-duplicated-deprecated-replyBodySpace
Closed

Maintenance: Removed deprecated Client::replyBodySpace()#2060
eduard-bagdasaryan wants to merge 2 commits into
squid-cache:masterfrom
measurement-factory:SQUID-1075-remove-duplicated-deprecated-replyBodySpace

Conversation

@eduard-bagdasaryan

@eduard-bagdasaryan eduard-bagdasaryan commented May 8, 2025

Copy link
Copy Markdown
Contributor

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.

The deprecated method was basically a duplicate of
Client::calcBufferSpaceToReserve().
Comment thread src/clients/FtpClient.cc
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());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The second parameter in removed replyBodySpace() is called minSpace. We passed 0.
  • The second parameter in calcBufferSpaceToReserve() is called wantSpace. We now pass spaceSize().

In both cases, the end result is exactly the same!

The value change makes sense because parameter names differ, and buffer spaceSize() is much closer to wantSpace than 0 would be -- we do not want to get rid of the existing buffer space. Neither value is actually "ideal" or "best", but improving requires difficult refactoring that lies outside this no-behavior-changes cleanup PR. We have several related TODOs/XXXs and runtime bugs. This small/simple PR helps with ongoing refactoring that will eventually address those. It is a small but useful step forward.

This comment does not request any PR changes.

@rousskov rousskov changed the title Removed deprecated Client::replyBodySpace() Maintenance: Removed deprecated Client::replyBodySpace() May 8, 2025
@rousskov rousskov added M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels S-could-use-an-approval An approval may speed this PR merger (but is not required) labels May 8, 2025
@yadij

yadij commented May 8, 2025

Copy link
Copy Markdown
Contributor

There is also the change of MemBuf::potentialSpaceSize() call to SBuf::maxSize which is much larger than MemBuf can store and lacks 0-termination consideration, which readBuf being a MemBuf still needs to be accounted for.

@rousskov

rousskov commented May 8, 2025

Copy link
Copy Markdown
Contributor

There is also the change of MemBuf::potentialSpaceSize() call to SBuf::maxSize which is much larger than MemBuf can store and lacks 0-termination consideration, which readBuf being a MemBuf still needs to be accounted for.

Yes, I have adjusted PR description to document that difference as well. The different code is never executed for the removed call and for the added one (because the corresponding if statement condition was and remains false), but we should still mention that if we are itemizing differences.

squid-anubis pushed a commit that referenced this pull request May 10, 2025
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.
@squid-anubis squid-anubis added M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-failed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-abandoned-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels labels May 10, 2025
@kinkie kinkie removed M-failed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-abandoned-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels labels May 11, 2025
squid-anubis pushed a commit that referenced this pull request May 11, 2025
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.
@squid-anubis squid-anubis added M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-failed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels labels May 11, 2025
@rousskov rousskov removed M-failed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels S-could-use-an-approval An approval may speed this PR merger (but is not required) labels May 11, 2025
squid-anubis pushed a commit that referenced this pull request May 11, 2025
Except for a trivial spaceSize() call and a never-executed (for the only
caller) `space` parameter adjustment, replyBodySpace() duplicates
Client::calcBufferSpaceToReserve(). That duplication complicates
refactoring aimed at addressing other known buffer management problems.
@squid-anubis squid-anubis added M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-failed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels labels May 11, 2025
@rousskov rousskov removed the M-failed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels label May 12, 2025
squid-anubis pushed a commit that referenced this pull request May 12, 2025
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.
@squid-anubis squid-anubis added M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-failed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels labels May 12, 2025
@yadij

yadij commented May 18, 2025

Copy link
Copy Markdown
Contributor

@eduard-bagdasaryan, our issues with github have now been resolved. You just need to rebase/merge the PR branch on latest master branch content (or click the "update branch" button on github UI that does it for you).

@yadij yadij added the S-waiting-for-author author action is expected (and usually required) label May 18, 2025
@eduard-bagdasaryan

Copy link
Copy Markdown
Contributor Author

Done, please remove the M-failed-staging-checks label to get it merged.

@rousskov rousskov removed S-waiting-for-author author action is expected (and usually required) M-failed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels labels May 19, 2025
squid-anubis pushed a commit that referenced this pull request May 19, 2025
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.
@squid-anubis squid-anubis added the M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels label May 19, 2025
@squid-anubis squid-anubis added M-merged https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels labels May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M-merged https://github.com/measurement-factory/anubis#pull-request-labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants