Skip to content

Conversation

samvrlewis
Copy link
Contributor

@samvrlewis samvrlewis commented Jan 28, 2022

Fixes a hang in fileio that would occur if any command had an error
during processing, causing the sbp reading thread to wait forever due to
never receiving its exit condition.

This moves all the potentially error-producing functions into closures,
so that the errors can be handled together.

Also:

  • Adds a hint as to why list may not be working
    (MSG_FILEIO_READ_DIR_RESP doesn't look like it's enabled by
    default)
  • Prints the list of files in the same way as the Python tool (to stdout,
    instead of to stderr) and prints each entry without the vec formatting.

I don't know for sure, but I suspect Stefan was seeing a hang as his PIksi may not have had MSG_FILEIO_READ_DIR_RESP enabled. With this message enabled, the list command did seem to work fine for me. This change will at least ensure the error is shown, if there is one.

Fixes a hang in fileio that would occur if any command had an error
during processing, causing the sbp reading thread to wait forever due to
never receiving its exit condition.

This moves all the potentially error-producing functions into closures,
so that the errors can be handled together.
The MSG_FILEIO_READ_DIR_RESP isn't enable to be output by default on
Piksis, so it would be useful to provide a hint to users as to why the
command may be timing out.
@samvrlewis samvrlewis requested review from a team and notoriaga January 28, 2022 09:16
timestamp = packet.timestamp,
level = packet.level,
msg = packet.msg,
spaces = spaces,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing issues for me (I guess I need to update to 1.58.0?) but figured the rest of the arguments are specified, so this one should probably be too, so I fixed it for consistency. 🤷‍♂️

print!("\rWriting {:.2}%...", progress);
})?;
println!("\nFile written successfully ({} bytes).", bytes_written);
let res = (|| {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of awkward, but is nice for convenience. I guess we could change each of these closures to be actual functions, or maybe we could use try_block for these? Happy to go with whatever people think is most readable.

Prints to stdout instead of stderror and prints each entry without the
list formatting
@notoriaga
Copy link
Contributor

Fixes a hang in fileio that would occur if any command had an error
during processing, causing the sbp reading thread to wait forever due to
never receiving its exit condition.

In #395 I switched from crossbeam threads to std::threads, which I think will also solve the issue? I'm assuming that the hanging was at the end of the closure passed to scope. scope will wait for any threads that were spawned inside it to join. Typically that's a nice property to have, but for something short lived like this I think not joining the thread is fine. And it avoids running into situations like this were we get stuck waiting for a thread that will never join.

Would wanna double check that this indeed fixes this issue, but if it does it's IMO a cleaner solution. It also avoids having to have the dedicated channel to kill the reader thread which is nice

@samvrlewis
Copy link
Contributor Author

In #395 I switched from crossbeam threads to std::threads, which I think will also solve the issue?

Ah, crap, sorry didn't notice that you had opened that! Will close this in preference to that PR then.

@samvrlewis samvrlewis closed this Jan 30, 2022
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.

4 participants