Repeating select call on Bridge when interrupted (#20)

* Repeating select if it is interrupted

* Restrict retries for syscall.EINTR to 10

Limit the number of retries on syscall.EINTR to 10.

---------

Co-authored-by: Pat Whittingslow <graded.sp@gmail.com>
This commit is contained in:
ddirect
2026-01-18 19:05:43 +02:00
committed by GitHub
parent 1a6ce6b056
commit 3c6882b4b3
+7
View File
@@ -284,8 +284,15 @@ func (br *Bridge) Poll(timeout time.Duration) (bool, error) {
Sec: int64(timeout / time.Second),
Usec: int64((timeout % time.Second) / time.Microsecond),
}
retry := 0
again:
n, err := syscall.Select(br.fd+1, &readfds, nil, nil, &tv)
retry++
if err != nil {
if err == syscall.EINTR && retry <= 10 {
// under linux, select updates tv with the remaining time
goto again
}
return false, err
}
return n > 0, nil