Fix EINTR not handled in LineRequest.WaitEdgeEventsRespectfully - #2599
Fix EINTR not handled in LineRequest.WaitEdgeEventsRespectfully#2599karen-meyerzuhartlage-AP wants to merge 1 commit into
LineRequest.WaitEdgeEventsRespectfully#2599Conversation
@dotnet-policy-service agree company="Anton Paar OptoTec GmbH" |
|
[Triage] Code looks ok, but we require a hardware test before approving. This may take some time. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a reliability issue in the libgpiod v2 GPIO edge-event waiting path by retrying epoll_wait when it fails with EINTR, matching the existing behavior in the libgpiod v1 event handler and preventing edge-event processing from stopping after suspend/resume.
Changes:
- Add an
EINTRretry loop aroundInterop.epoll_waitinLineRequest.WaitEdgeEventsRespectfully. - Introduce an
ERROR_CODE_EINTRconstant in the v2LineRequestproxy to align with existing drivers’ interrupt-handling patterns.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| var errorCode = Marshal.GetLastWin32Error(); | ||
|
|
||
| if (errorCode == ERROR_CODE_EINTR) | ||
| { | ||
| // ignore Interrupted system call error and retry | ||
| continue; | ||
| } | ||
|
|
||
| throw new GpiodException($"Error while waiting for edge events, epoll_wait: {LastErr.GetMsg()}"); |
Fixes #2598
Related to #1210
LineRequest.WaitEdgeEventsRespectfully(used byLibGpiodV2Driver) callsInterop.epoll_waitwithout handlingEINTR(errno 4). If the call is interrupted by a signal — which happens when a device resumes from standby/suspend — the method throws aGpiodExceptioninstead of retrying.The V1
LibGpiodDriverEventHandleralready ignoresInterrupted system callerror and continues waiting for events (see #1210). This PR implements the same behaviour forLibGpiodV2Driver.Microsoft Reviewers: Open in CodeFlow