As per https://github.com/Haivision/srtgo/pull/63 (and https://github.com/Haivision/srtgo/pull/58, but the fixes aren't as nice)...
SetDeadline has a few silly mistakes:
Issue 1) When the poll descriptor is created, it is with a duration of 0, which causes the deadline timer to fire right away and that's waiting the next time a deadline is set up.
Issue 2) If there is a delay between setting up deadlines, and the timer fired after the poll.Wait() had returned, that timer signal is not cleared from the channel and will cause wait to return immediately.
Issue 3) The return value from poll.Wait() is not checked in the Read and Write functions, which will cause a Read to hang if there is no data on the socket
Example of 1:
socket, socketCreateErr = srtgo.NewSrtSocket(s.host, s.port, s.options)
spa.socket.SetWriteDeadline() // Use deadline
err := socket.Connect() // Will return immediately, because the deadline timer fires immediately
Example of 3:
socket, socketCreateErr = srtgo.NewSrtSocket(s.host, s.port, s.options)
err := socket.Connect()
socket.ReadPacket(srtPacket) // Will wait forever, because there isn't actually a check if the deadline has been met.
As per my experiments...
Issue 4) SetWriteDeadline is currently equivalent to both SetReadDeadline and SetWriteDeadline, due to a silly mistake.
As per
https://github.com/Haivision/srtgo/pull/63
(andhttps://github.com/Haivision/srtgo/pull/58
, but the fixes aren't as nice)...SetDeadline has a few silly mistakes:
Issue 1) When the poll descriptor is created, it is with a duration of 0, which causes the deadline timer to fire right away and that's waiting the next time a deadline is set up. Issue 2) If there is a delay between setting up deadlines, and the timer fired after the poll.Wait() had returned, that timer signal is not cleared from the channel and will cause wait to return immediately. Issue 3) The return value from poll.Wait() is not checked in the Read and Write functions, which will cause a Read to hang if there is no data on the socket
Example of 1:
Example of 3:
As per my experiments...
Issue 4)
SetWriteDeadline
is currently equivalent to bothSetReadDeadline
andSetWriteDeadline
, due to a silly mistake.