Repository navigation
utmpx: handle unavailable logind session metadata - #16568
mattsu2020 wants to merge 4 commits into
Conversation
35f3e69 to
73a2c08
Compare
|
GNU testsuite comparison: |
73a2c08 to
ebef859
Compare
Merging this PR will improve performance by 51.62%2 warnings, 1 note
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
| continue; | ||
| }; | ||
| let start_time = start_time | ||
| .filter(|usec| *usec > 0) |
There was a problem hiding this comment.
the zero time is checked here, in get_session_start_time and in try_login_time_offset. once should be enough, no?
|
|
||
| /// Get the login time, or the Unix epoch when it is unavailable. | ||
| /// Use [`Self::try_login_time_offset`] when displaying timestamps. | ||
| pub fn login_time_offset(&self) -> time::OffsetDateTime { |
There was a problem hiding this comment.
is this still used outside the test? looks like dead code now, same for the compat login_time()/pid()
There was a problem hiding this comment.
The compat login_time() and pid() methods are still used by UtmpxRecord
| use super::*; | ||
|
|
||
| #[test] | ||
| fn missing_metadata_preserves_legacy_api_types() { |
There was a problem hiding this comment.
what does this test check? the let x: Type lines don't test much
|
|
||
| #[cfg(test)] | ||
| #[path = "systemd_logind/tests.rs"] | ||
| mod regression_tests; |
There was a problem hiding this comment.
why a second test module in a separate file? please move these into the existing mod tests
| /// Returns None when logind could not provide a session leader PID. | ||
| #[cfg_attr( | ||
| not(all(target_os = "linux", feature = "systemd_logind")), | ||
| allow(clippy::unnecessary_wraps) |
There was a problem hiding this comment.
please avoid the allow(), maybe just change pid()/login_time() to return an Option
|
|
||
| #[test] | ||
| fn unavailable_time_and_pid_are_question_marks() { | ||
| let record = UtmpxRecord::Systemd(SystemdUtmpxCompat::new(SystemdLoginRecord { |
There was a problem hiding this comment.
the same record is built in 4 tests, could be a small helper in uucore?
Depends on #16478. Related to #8376. Split from #11579.
Review this change.