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

watched_tasks: improve error handling in spawned tasks and threads #48

Merged
merged 4 commits into from
Jun 25, 2024

Conversation

hnez
Copy link
Member

@hnez hnez commented Oct 2, 2023

This PR adds some of the improved error handling that is hinted at in #47. For now that means:

  • Simplify error handling in src/dut_power.rs
  • Simplify error handling in src/adc/iio/hardware.rs

Todo

  • [ ] Find even more places where error handling in tasks can be improved
    We can do that in subsequent PRs

Related Pull Requests

This PR is based on another PR that should be merged first:

@hnez
Copy link
Member Author

hnez commented Oct 4, 2023

The failed cargo deny run should be fixed by the dependency updates in #42 and has nothing to do with this PR.

@hnez
Copy link
Member Author

hnez commented Nov 23, 2023

Assigned to myself because #47 (which this is based on) still needs some work on my side.

@hnez hnez force-pushed the error-handling branch 4 times, most recently from cf2851d to 61bfafe Compare January 19, 2024 14:59
@hnez hnez assigned KarlK90 and unassigned hnez Jan 19, 2024
@hnez hnez marked this pull request as ready for review January 19, 2024 15:01
@hnez
Copy link
Member Author

hnez commented Apr 2, 2024

Pull request #58 has changed the logic in src/dut_power.rs a bit, making the rebase non-trivial.
I will have to look into that some other time and will assign this PR back to me for the time being.

@hnez hnez assigned hnez and unassigned KarlK90 Apr 2, 2024
@hnez hnez force-pushed the error-handling branch 2 times, most recently from ae48497 to c14e10f Compare May 24, 2024 11:45
@hnez hnez assigned KarlK90 and unassigned hnez May 24, 2024
@hnez
Copy link
Member Author

hnez commented May 24, 2024

I've resolved the merge conflicts now and have also split the changes into a few more commits.

hnez added 3 commits June 25, 2024 08:36
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
The operating system call to set the GPIO output state may fail.
Make sure that this results in an orderly teardown of the tacd instead
of a panic.

This also necessitates a change to the test and demo_mode gpio stubs,
so they can be `?`-operatored into anyhow Results (simply by making
them anyhow results).

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Since we can now return early from `wtb.spawn_thread`-spawned threads,
because they handle error propagation out of the thread context for us
we no longer have to use queues to send back error results manually.

Use that to simplify error handling in the thread setup and the steady
state.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Now that errors from threads are properly propagated we can simplify
the error handling and do not have to transfer `Result`s across queues
if something goes wrong during thread setup.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
@hnez hnez merged commit c75d701 into linux-automation:main Jun 25, 2024
10 checks passed
@hnez hnez deleted the error-handling branch June 25, 2024 08:44
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.

3 participants