Skip to content

Add HttpTransact::get_max_age and TSHttpTxnGetMaxAge - #6730

Merged
zwoop merged 1 commit into
apache:masterfrom
ema:maxage
May 12, 2020
Merged

zwoop merged 1 commit into
apache:masterfrom
ema:maxage

Conversation

@ema

@ema ema commented May 1, 2020

Copy link
Copy Markdown
Contributor

Add a new function called HttpTransact::get_max_age based on the logic
in HttpTransact::calculate_document_freshness_limit that extracts
max_age depending on s-maxage and max-age. Expose the function as
TSHttpTxnGetMaxAge.

@jvgutierrez

Copy link
Copy Markdown
Member

@ema please run tools/clang-format.sh on your branch. Also TS API changes should be discussed on the dev mailing list IIRC.

Comment thread proxy/http/HttpTransact.cc Outdated
}

int
HttpTransact::get_max_age(State *s, HTTPHdr *response)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why is the State object a parameter to this function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question, state is needed by TxnDebug. I have kept the two debugging statements (printing s_maxage or max_age depending on which one is defined) because they were used in calculate_document_freshness_limit. If we decide that they are not needed, after all, then we can avoid passing State as a parameter to the function.

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.

My general thought it that we should avoid duplicating Debug()'s which are already in the core. It's not intended for debugging "line-by-line" code, but rather, show internal stats, transitions, state machine states etc. as the request is being processed.

So, assuming there's an existing Debug that shows the max-age, we should remove it here.

@ema ema May 12, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My general thought it that we should avoid duplicating Debug()'s which are already in the core. It's not intended for debugging "line-by-line" code, but rather, show internal stats, transitions, state machine states etc. as the request is being processed.

So, assuming there's an existing Debug that shows the max-age, we should remove it here.

I couldn't find any, so I've re-added one single debug statement showing max-age to calculate_document_freshness_limit. Let me know if this looks any better!

Add a new function called HttpTransact::get_max_age based on the logic
in HttpTransact::calculate_document_freshness_limit that extracts
max_age depending on s-maxage and max-age. Expose the function as
TSHttpTxnGetMaxAge.
freshness_limit = std::min(std::max(0, freshness_limit), static_cast<int>(s->txn_conf->cache_guaranteed_max_lifetime));
if (max_age >= 0) {
freshness_limit = std::min(std::max(0, max_age), static_cast<int>(s->txn_conf->cache_guaranteed_max_lifetime));
TxnDebug("http_match", "calculate_document_freshness_limit --- freshness_limit = %d", freshness_limit);

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.

Perfect!

@zwoop
zwoop merged commit 4575058 into apache:master May 12, 2020
@zwoop

zwoop commented May 12, 2020

Copy link
Copy Markdown
Contributor

Cherry-picked to v9.0.x branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants