Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ext_time_quota_acl: convert to c++ #1847

Closed
wants to merge 65 commits into from

Conversation

kinkie
Copy link
Contributor

@kinkie kinkie commented Jun 24, 2024

Make use of dynamically-allocated strings
instead of static buffers, and convert debug output
to use Squid's Debug API

Inspired by addressing Coverity CID 1461163
"Invalid type in argument to printf format specifier"

@squid-anubis squid-anubis added the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Jun 24, 2024
@kinkie
Copy link
Contributor Author

kinkie commented Jun 24, 2024

This has been runtime-tested:

./btbuild/src/acl/external/time_quota/ext_time_quota_acl -d -n -b /tmp/db ../timequota.def
1719265571 INFO| Starting ./btbuild/src/acl/external/time_quota/ext_time_quota_acl
1719265571 INFO| opening time quota database "/tmp/db".
1719265571 DEBUG| Database contains 17 entries.
1719265571 INFO| reading config file "../timequota.def".
1719265571 DEBUG| read config line 2: "john 8h / 1d"
1719265571 DEBUG| read time quota for user "john": 28800s / 86400s starting 1719187200
1719265571 DEBUG| writeTime("john-period-start", 1719187200)
1719265571 DEBUG| writeTime("john-period-length-configured", 86400)
1719265571 DEBUG| writeTime("john-time-budget-configured", 28800)
1719265571 DEBUG| readTime("john-time-budget-configured")=28800
1719265571 DEBUG| writeTime("john-time-budget-left", 28800)
1719265571 DEBUG| read config line 3: "littlejoe 1h / 1d"
1719265571 DEBUG| read time quota for user "littlejoe": 3600s / 86400s starting 1719187200
1719265571 DEBUG| writeTime("littlejoe-period-start", 1719187200)
1719265571 DEBUG| writeTime("littlejoe-period-length-configured", 86400)
1719265571 DEBUG| writeTime("littlejoe-time-budget-configured", 3600)
1719265571 DEBUG| readTime("littlejoe-time-budget-configured")=3600
1719265571 DEBUG| writeTime("littlejoe-time-budget-left", 3600)
1719265571 DEBUG| read config line 4: "babymary 30m / 1w"
1719265571 DEBUG| read time quota for user "babymary": 1800s / 604800s starting 1719187200
1719265571 DEBUG| writeTime("babymary-period-start", 1719187200)
1719265571 DEBUG| writeTime("babymary-period-length-configured", 604800)
1719265571 DEBUG| writeTime("babymary-time-budget-configured", 1800)
1719265571 DEBUG| readTime("babymary-time-budget-configured")=1800
1719265571 DEBUG| writeTime("babymary-time-budget-left", 1800)
1719265571 DEBUG| read config line 5: "short 1m / 1h"
1719265571 DEBUG| read time quota for user "short": 60s / 3600s starting 1719262800
1719265571 DEBUG| writeTime("short-period-start", 1719262800)
1719265571 DEBUG| writeTime("short-period-length-configured", 3600)
1719265571 DEBUG| writeTime("short-time-budget-configured", 60)
1719265571 DEBUG| readTime("short-time-budget-configured")=60
1719265571 DEBUG| writeTime("short-time-budget-left", 60)
1719265571 INFO| Waiting for requests...
short
1719265573 DEBUG| processActivity("short")
1719265573 DEBUG| readTime("short-period-start")=1719262800
1719265573 DEBUG| readTime("short-period-length-configured")=3600
1719265573 DEBUG| readTime("short-last-activity")=1719265499
1719265573 DEBUG| writeTime("short-last-activity", 1719265573)
1719265573 DEBUG| Time budget reduced by 74 for user "short".
1719265573 DEBUG| readTime("short-time-budget-left")=60
1719265573 DEBUG| writeTime("short-time-budget-left", -14)
1719265573 DEBUG| readTime("short-time-budget-left")=-14
1719265573 DEBUG| ERR message="Remaining quota for 'short' is -14 seconds."
ERR Time budget exceeded.
1719265577 INFO| Ending ./btbuild/src/acl/external/time_quota/ext_time_quota_acl

@kinkie kinkie changed the title ext_time_quota_acl: convert to c++ ext_time_quota_acl: convert to c++ streams Jun 24, 2024
@squid-anubis squid-anubis removed the M-failed-description https://github.com/measurement-factory/anubis#pull-request-labels label Jun 24, 2024
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

This is a partial review in hope to help you may steady progress with this helper conversion.

src/acl/external/time_quota/ext_time_quota_acl.cc Outdated Show resolved Hide resolved
src/acl/external/time_quota/ext_time_quota_acl.cc Outdated Show resolved Hide resolved
src/acl/external/time_quota/ext_time_quota_acl.cc Outdated Show resolved Hide resolved
src/acl/external/time_quota/ext_time_quota_acl.cc Outdated Show resolved Hide resolved
src/acl/external/time_quota/ext_time_quota_acl.cc Outdated Show resolved Hide resolved
@rousskov rousskov added the S-waiting-for-author author action is expected (and usually required) label Jun 24, 2024
src/acl/external/time_quota/ext_time_quota_acl.cc Outdated Show resolved Hide resolved
src/acl/external/time_quota/ext_time_quota_acl.cc Outdated Show resolved Hide resolved
src/acl/external/time_quota/ext_time_quota_acl.cc Outdated Show resolved Hide resolved
src/acl/external/time_quota/ext_time_quota_acl.8 Outdated Show resolved Hide resolved
kinkie and others added 8 commits July 1, 2024 08:29
@kinkie kinkie removed the S-waiting-for-author author action is expected (and usually required) label Aug 12, 2024
yadij
yadij previously approved these changes Aug 12, 2024
Copy link
Contributor

@yadij yadij left a comment

Choose a reason for hiding this comment

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

Thank you. Looks good enough to me.
Just waiting on @rousskov discussions now.

@rousskov
Copy link
Contributor

Just waiting on @rousskov discussions now.

FWIW, I have nothing to add to my last outstanding change request. That code changed a bit, but the problem remains. The ball there is on @kinkie side.

@rousskov rousskov added S-waiting-for-author author action is expected (and usually required) and removed S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box labels Aug 12, 2024
@kinkie
Copy link
Contributor Author

kinkie commented Aug 12, 2024

Just waiting on @rousskov discussions now.

FWIW, I have nothing to add to my last outstanding change request. That code changed a bit, but the problem remains. The ball there is on @kinkie side.

For some reason this was not appearing in my log.
I'm adopting the "improved" version, minus the Debug::Extra bits which I find functionally bad due to not allowing easy grep(1)-ing.

@kinkie kinkie added S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box and removed S-waiting-for-author author action is expected (and usually required) labels Aug 12, 2024
@kinkie kinkie requested a review from rousskov August 12, 2024 17:13
Also added a trailing `<<` to ease source code
comprehension, search, and adaptation.
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

Still no objections to this PR going in...

src/acl/external/time_quota/ext_time_quota_acl.cc Outdated Show resolved Hide resolved
@rousskov rousskov added S-waiting-for-author author action is expected (and usually required) and removed S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box labels Aug 12, 2024
squid-anubis pushed a commit that referenced this pull request Aug 13, 2024
Make use of dynamically-allocated strings
instead of static buffers, and convert debug output
to use Squid's Debug API

Inspired by addressing Coverity CID  1461163
"Invalid type in argument to printf format specifier"
@squid-anubis squid-anubis added M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-passed-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 Aug 13, 2024
@kinkie kinkie added M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels and removed S-waiting-for-author author action is expected (and usually required) labels Aug 13, 2024
@squid-anubis squid-anubis added M-merged https://github.com/measurement-factory/anubis#pull-request-labels and removed M-passed-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 Aug 13, 2024
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.

4 participants