mirror of
https://github.com/soypat/lneto.git
synced 2026-08-12 19:03:42 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user