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

pv: add monotonic clock to TimeVal pseudovariable #3191

Merged
merged 1 commit into from Aug 23, 2022

Conversation

xadhoom
Copy link

@xadhoom xadhoom commented Jul 19, 2022

Pre-Submission Checklist

  • Commit message has the format required by CONTRIBUTING guide
  • Commits are split per component (core, individual modules, libs, utils, ...)
  • Each component has a single commit (if not, squash them into one commit)
  • No commits to README files for modules (changes must be done to docbook files
    in doc/ subfolder, the README file is autogenerated)

Type Of Change

  • Small bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds new functionality)
  • Breaking change (fix or feature that would change existing functionality)

Checklist:

  • PR should be backported to stable branches
  • Tested changes locally
  • Related to issue #XXXX (replace XXXX with an open issue number)

Description

Sometime is helpful to have a monotonic timer to attach to events in order to discard out-of-order ones on receiving side. Current time values are not ideal since are subject to clock skews, adjustment and so on. Since we have system monotonic clock we can use that value to have a monotonic counter.

To be 100% fair CLOCK_MONOTONIC can still be skewed only by ntp adjustment, that's why we try to use CLOCK_MONOTONIC_RAW which is linux-only (afaik) that do not suffer from such adjustments.

The new pseudovariable is $TV(Sm), which returns the monotonic counter as a string. Note that even if is based on clock, it starts from an unspecified point in time, so should really be treated as an always increasing counter.

- adds $TV(Sm) pseudovariable which returns the system monotonic clock
  as a string
- on Linux, tries to use CLOCK_MONOTONIC_RAW which does not suffer from
  ntp time adjustement
@henningw
Copy link
Contributor

Thanks for the pull-request. Could you also please add the documentation for the new PV in our wiki? Then it could be probably merged, if no other comments come in.

@xadhoom
Copy link
Author

xadhoom commented Aug 10, 2022 via email

@xadhoom
Copy link
Author

xadhoom commented Aug 23, 2022

Done in kamailio/kamailio-wiki#14

@henningw henningw merged commit 5d09caf into kamailio:master Aug 23, 2022
@henningw
Copy link
Contributor

Thanks, merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants