-
-
Notifications
You must be signed in to change notification settings - Fork 10
Add monotonic_usec #12
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
Conversation
Are you sure that
and the implementation is not guaranteed:
https://doc.rust-lang.org/std/time/struct.SystemTime.html Does systemd compare the sent time stamp to I think sd-notify should call |
Thanks for the PR. I agree, that should be I'm not sure how I feel about us sending it automatically. At this time (heh), it's documented as:
I don't see any other use case for it, but:
Overall, I was in favour of not sending it automatically, but it feels like we should just handle it on our side. |
Seems we were not the only one bitten: https://gitlab.isc.org/isc-projects/bind9/-/issues/4377 So I think if a reload message is sent you have to send a monotonic clock message too :( |
Yep, my mistake :) |
Need to finish fixing the error handling now btw. |
@lnicola With the call to monotonic_time_usecs since that returns io::Result, but in Display we need fmt::Result, do you think we make MonotonicUsec take the i128 and we expose the monotonic_usec fn? Alternately we could do a constructor on NotifyState::monotonic_usec_now() |
Yeah, let's store it in there and add |
Okay, should be good for another review :) |
I just pushed a commit to your branch to clean things up a little, can you take a look? Also r? @mbuesch since you're here 😛. |
@lnicola Yep, thank you! Looks good :) |
683a62c
to
64ca63c
Compare
/// # Example | ||
/// | ||
/// ``` | ||
/// # use sd_notify::NotifyState; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This didn't build (no_run
is "don't run", not "don't build"), but should be fine to run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean?
cargo test
...
test src/lib.rs - NotifyState<'_>::monotonic_usec_now (line 116) ... ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add the use
, otherwise:
---- src/lib.rs - NotifyState<'_>::monotonic_usec_now (line 116) stdout ----
error[E0433]: failed to resolve: use of undeclared type `NotifyState`
--> src/lib.rs:118:9
|
4 | let _ = NotifyState::monotonic_usec_now().expect("Failed to read monotonic time");
| ^^^^^^^^^^^ use of undeclared type `NotifyState`
|
help: consider importing this enum
|
3 + use sd_notify::NotifyState;
|
And we can remove no_run
since it doesn't do anything bad.
Not sure how it passed CI, maybe it didn't run?
64ca63c
to
6777699
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks to all of you involved :)
No problem, happy to have helped! |
6777699
to
5462699
Compare
I squashed and force-pushed, but tried to preserve the attribution, hope you don't mind. Thanks for the PR! |
Available at https://crates.io/crates/sd-notify/0.4.4. |
Thank you so much! |
Resolve #11 - add support for the monotonic-usec notification that is required from v253 and onwards for reload to succeed.