浏览代码

in the case where there is a timeout, we should attempt again

Eric Balsa 3 月之前
父节点
当前提交
b3c50fc411
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      v4l2/syscalls.go

+ 6 - 1
v4l2/syscalls.go

@@ -98,11 +98,16 @@ func WaitForRead(dev Device) <-chan struct{} {
 			fdsRead.Zero()
 			fdsRead.Set(int(fd))
 			tv := sys.Timeval{Sec: 2, Usec: 0}
-			_, errno := sys.Select(int(fd+1), &fdsRead, nil, nil, &tv)
+			n, errno := sys.Select(int(fd+1), &fdsRead, nil, nil, &tv)
 			if errno == sys.EINTR {
 				continue
 			}
 
+			if n == 0 {
+				// timeout, no data available
+				continue
+			}
+
 			sigChan <- struct{}{}
 		}
 	}(dev.Fd())