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

Do not pass static zero IntPtr to epoll wait. Dispose driver in tests… #2291

Merged
merged 1 commit into from
Mar 18, 2024

Conversation

huesla
Copy link
Contributor

@huesla huesla commented Mar 9, 2024

See here
This PR fixes a bug introduced by the merge of #2184.
The bug was introduced by an unintentional change in the behaviour of the SysFsDriver, that utilizes the native epoll_wait function to discard not needed events.
Originally the binding of epoll_wait was implemented as
public static extern int epoll_wait(int epfd, out epoll_event events, int maxevents, int timeout);
which does not fully match the native function
int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout);
because events is a pointer to an array.

Some new functionality in #2184 relies on epoll_wait, what prompted me to correct the binding.
As a consequence I had to update calls in the SysFsDriver, but mistakenly passed IntPtr.Zero to epoll_wait, which does not seem to result in the same behaviour. The fix is to pass an actual buffer instead.

This PR also includes some additional "using" statements in the GpioControllerTestBase because during testing, some sporadic occurrences of PermissionDeniedException occured. It complained about not having root permission for changing GPIO mode of used GPIOs. I'm pretty sure that was because of not yet disposed SysFsDriver instance/s.

Microsoft Reviewers: Open in CodeFlow

@pgrawehr
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@pgrawehr pgrawehr left a comment

Choose a reason for hiding this comment

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

Thanks for this fix and the quick reaction. That looks much greener now 🟢

Copy link
Member

@Ellerbach Ellerbach left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, indeed, seems to fix the issues :-)

@pgrawehr pgrawehr merged commit ab3f910 into dotnet:main Mar 18, 2024
10 checks passed
@huesla huesla deleted the fix-sysfsdriver branch March 18, 2024 17:12
@github-actions github-actions bot locked and limited conversation to collaborators Apr 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants