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

await_next_record(None) returns Ok(None) when JournalFiles::CurrentUser is used #53

Open
bddap opened this issue Sep 25, 2018 · 2 comments

Comments

@bddap
Copy link

bddap commented Sep 25, 2018

Passing None to await_next_record() indicates an infinite timeout so a timeout should never happen, yet a timeout is indicated. await_next_record() sometimes returns Ok(None), indicating a timeout.

extern crate systemd;
use systemd::journal::{Journal, JournalFiles};

fn main() {
    let mut journal = Journal::open(JournalFiles::CurrentUser, false, false).unwrap();
    let record = journal.await_next_record(None).unwrap();
    assert!(record.is_some()); // Panics
}
@bddap
Copy link
Author

bddap commented Sep 25, 2018

Suggested Change

To start, the "No timeout" contract should be enforced through types.

pub fn await_next_record(&mut self,  wait_time: Option<Duration>) ->
Result<Option<JournalRecord>>

should be changed to

pub fn await_next_record(&mut self, wait_time: Duration) ->
Result<Option<JournalRecord>>

Then a new method can be added:

pub fn await_next_record_no_timeout(&mut self) -> Result<JournalRecord>

@codyps
Copy link
Owner

codyps commented Oct 1, 2018

That seems reasonable, I'd have no problem accepting a change that did this.

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

No branches or pull requests

2 participants