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

maxage calculation is changed #514

Closed
banjiuqingshan opened this issue May 4, 2023 · 4 comments · Fixed by #516
Closed

maxage calculation is changed #514

banjiuqingshan opened this issue May 4, 2023 · 4 comments · Fixed by #516

Comments

@banjiuqingshan
Copy link

With maxage set, any log file older than N days will to be purged.The relevant discussion can be seen in #39.

@banjiuqingshan
Copy link
Author

The use of difftime has caused this difference.
4eb3add

@kdudka
Copy link
Member

kdudka commented May 4, 2023

I do not understand what exactly is wrong and what should be changed.

@banjiuqingshan
Copy link
Author

Before 4eb3add, when maxage was set to 1, files from 48 hours ago were not deleted and only deleted after 48 hours or more. Now, they will be deleted after 24 hours or more

kdudka added a commit to kdudka/logrotate that referenced this issue May 5, 2023
... to restore the original behavior of `logrotate-3.19.0`, before
we started to use difftime(), which returns a floating point number.

Fixes: logrotate#514
Closes: https://github.com/logrotate/logrotate/pulls/515
@kdudka
Copy link
Member

kdudka commented May 5, 2023

Got it, thanks! I have proposed pull request #515 to fix this.

kdudka added a commit to kdudka/logrotate that referenced this issue May 5, 2023
... to restore the original behavior of `logrotate-3.19.0`, before we
started to use `difftime()`, which returns a floating point number.

Fixes: logrotate#514
Closes: logrotate#515
cgzones added a commit to cgzones/logrotate that referenced this issue May 5, 2023
cgzones added a commit to cgzones/logrotate that referenced this issue May 5, 2023
With the introduction of difftime(3) in commit 4eb3add ("Use difftime
to compare time_t") to support platform with an unsigned time_t several
arithmetic operations and comparisons turned from integer to floating
point ones.  This can lead to different results since integer divisions
round down to the next integer while floating point divisions do not.

Cast the result of difftime(3) to intmax_t to revert back to integer
operations.

Fixes: 4eb3add ("Use difftime to compare time_t")
Fixes: logrotate#514
cgzones added a commit to cgzones/logrotate that referenced this issue May 5, 2023
cgzones added a commit to cgzones/logrotate that referenced this issue May 5, 2023
With the introduction of difftime(3) in commit 4eb3add ("Use difftime
to compare time_t") to support platform with an unsigned time_t several
arithmetic operations and comparisons turned from integer to floating
point ones.  This can lead to different results since integer divisions
round down to the next integer while floating point divisions do not.

Cast the result of difftime(3) to intmax_t to revert back to integer
operations.

Fixes: 4eb3add ("Use difftime to compare time_t")
Fixes: logrotate#514
cgzones added a commit to cgzones/logrotate that referenced this issue May 9, 2023
cgzones added a commit to cgzones/logrotate that referenced this issue May 9, 2023
With the introduction of difftime(3) in commit 4eb3add ("Use difftime
to compare time_t") to support platform with an unsigned time_t several
arithmetic operations and comparisons turned from integer to floating
point ones.  This can lead to different results since integer divisions
round down to the next integer while floating point divisions do not.

Cast the result of difftime(3) to intmax_t to revert back to integer
operations.

Fixes: 4eb3add ("Use difftime to compare time_t")
Fixes: logrotate#514
cgzones added a commit to cgzones/logrotate that referenced this issue Jun 7, 2023
cgzones added a commit to cgzones/logrotate that referenced this issue Jun 7, 2023
With the introduction of difftime(3) in commit 4eb3add ("Use difftime
to compare time_t") to support platform with an unsigned time_t several
arithmetic operations and comparisons turned from integer to floating
point ones.  This can lead to different results since integer divisions
round down to the next integer while floating point divisions do not.

Cast the result of difftime(3) to intmax_t to revert back to integer
operations.

Fixes: 4eb3add ("Use difftime to compare time_t")
Fixes: logrotate#514
cgzones added a commit that referenced this issue Jun 30, 2023
cgzones added a commit that referenced this issue Jun 30, 2023
With the introduction of difftime(3) in commit 4eb3add ("Use difftime
to compare time_t") to support platform with an unsigned time_t several
arithmetic operations and comparisons turned from integer to floating
point ones.  This can lead to different results since integer divisions
round down to the next integer while floating point divisions do not.

Cast the result of difftime(3) to intmax_t to revert back to integer
operations.

Fixes: 4eb3add ("Use difftime to compare time_t")
Fixes: #514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants