(connFd int)
| 232 | type pollFunc func(fds []unix.PollFd, timeout *unix.Timespec, sigmask *unix.Sigset_t) (int, error) |
| 233 | |
| 234 | func waitForHWTS(connFd int) error { |
| 235 | return pollForHWTS(connFd, unix.Ppoll) |
| 236 | } |
| 237 | |
| 238 | // pollForHWTS waits until the TX timestamp is ready, for at most TimeoutTXTS. |
| 239 | // unix.Poll is deliberately not used: it takes whole milliseconds as an int and |
| 240 | // passes anything negative to ppoll as "no timeout", so a lossy conversion there |
| 241 | // would reintroduce the unbounded wait this deadline exists to prevent. |
| 242 | func pollForHWTS(connFd int, poll pollFunc) error { |
| 243 | fds := []unix.PollFd{{Fd: int32(connFd), Events: unix.POLLERR, Revents: 0}} //nolint:gosec // fd is always small |
| 244 | // a restarted poll must share one deadline, otherwise every EINTR grants |
| 245 | // another full TimeoutTXTS and the caller's attempt budget bounds nothing |
| 246 | deadline := time.Now().Add(TimeoutTXTS) |
| 247 | for { |
| 248 | remaining := time.Until(deadline) |
| 249 | if remaining <= 0 { |
no outgoing calls
no test coverage detected
searching dependent graphs…