未验证 提交 52e817c8 编写于 作者: R RD-AP-PPT 提交者: GitHub

ignore Interrupted system call error and retry (#1499)

上级 531b984e
......@@ -11,6 +11,8 @@ namespace System.Device.Gpio.Drivers
{
internal sealed class LibGpiodDriverEventHandler : IDisposable
{
private const int ERROR_CODE_EINTR = 4; // Interrupted system call
private static string s_consumerName = Process.GetCurrentProcess().ProcessName;
public event PinChangeEventHandler? ValueRising;
......@@ -55,7 +57,14 @@ namespace System.Device.Gpio.Drivers
WaitEventResult waitResult = Interop.libgpiod.gpiod_line_event_wait(pinHandle, ref timeout);
if (waitResult == WaitEventResult.Error)
{
throw ExceptionHelper.GetIOException(ExceptionResource.EventWaitError, Marshal.GetLastWin32Error(), _pinNumber);
var errorCode = Marshal.GetLastWin32Error();
if (errorCode == ERROR_CODE_EINTR)
{
// ignore Interrupted system call error and retry
continue;
}
throw ExceptionHelper.GetIOException(ExceptionResource.EventWaitError, errorCode, _pinNumber);
}
if (waitResult == WaitEventResult.EventOccured)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册