Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add various fixes for SetDeadline functionality #3

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

nlon982
Copy link

@nlon982 nlon982 commented Apr 4, 2024

As per Haivision#63 (and Haivision#58)...

Fixes for SetDeadline:

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. This is the reason this synchroniser test breaks: TestMpegTSContextReadRawSRTRTPPacketsMultiInput

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.


TODO:

  • Confirm it works
    • Use SetWriteDeadline before Connect in srtsocket.go
    • Use SetReadDeadline before ReadPackets in srtsocket.go
    • Confirm tests work: TestMpegTSContextReadRawSRTRTPPacketsMultiInput and TestInputStreamRecorderSrtStream
  • Remove temp comments and logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant