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

porting/npl/linux: Handle EINTR from sem_timedwait #1855

Merged
merged 1 commit into from
Sep 6, 2024

Conversation

rojer
Copy link
Contributor

@rojer rojer commented Sep 2, 2024

It's been observed that sem_timedwait() can return EINTR even if sigaction() specified SA_RESTART.

Not sure what the deal with that is but handling it is simple enough.

@github-actions github-actions bot added the size/XS Extra small PR label Sep 2, 2024
return BLE_NPL_TIMEOUT;
while ((err = sem_timedwait(&sem->lock, &wait)) != 0) {
switch (errno) {
case EINTR: continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be

case EINTR:
    continue;
case ETIMEDOUT:
    return BLE_NPL_TIMEOUT;

I also wonder if there should be default case with assert maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed style.
in the default case we fall through to return BLE_NPL_ERROR and stack restart is attempted.
it happens to fail and assert but that's another story[1]. In theory a stack restart is the right thing to do in this case and might fix things.

[1] Assert happens here because ble_hs_sched_reset here bites on its own tail - tries to tx a reset command.

@github-actions github-actions bot added the size/S Small PR label Sep 6, 2024
It's been observed that `sem_timedwait()` can return `EINTR` even if `sigaction()` specified `SA_RESTART`.

Not sure what the deal with that is but handling it is simple enough.
@rojer
Copy link
Contributor Author

rojer commented Sep 6, 2024

fixed whitespace, sorry

@sjanc
Copy link
Contributor

sjanc commented Sep 6, 2024

no worries, and thanks for contributing :)

@sjanc sjanc merged commit 42e5a28 into apache:master Sep 6, 2024
18 checks passed
@rojer rojer deleted the sem_timedwait_resume branch September 10, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S Small PR size/XS Extra small PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants