Skip to content
New issue

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

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

Already on GitHub? # to your account

Prevent sending TCP packets to a closed connection. #691

Closed
wants to merge 1 commit into from

Conversation

jean343
Copy link

@jean343 jean343 commented Feb 4, 2025

Fixes #689

This pull request includes an important change to the writePacketRTP function in the server_session.go file to ensure thread safety when accessing the writer object.

Thread safety improvements:

Added a read lock (RLock) and corresponding unlock (RUnlock) around the writer access in the writePacketRTP function to prevent concurrent access issues. Also added a nil check for writer to handle cases where it might be nil.

Bug was caused by setting tcpConn to nil on RTSP pause. The async writer would keep pulling in packets and sending them to tcpConn even after the connection has been marked nil.

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.00%. Comparing base (07039eb) to head (227eea1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
server_session.go 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #691   +/-   ##
=======================================
  Coverage   82.00%   82.00%           
=======================================
  Files         120      120           
  Lines       12464    12468    +4     
=======================================
+ Hits        10221    10225    +4     
  Misses       1825     1825           
  Partials      418      418           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aler9
Copy link
Member

aler9 commented Feb 7, 2025

replaced by #692

@aler9 aler9 closed this Feb 7, 2025
@jean343
Copy link
Author

jean343 commented Feb 8, 2025

Thank you for fixing this issue. I confirm that the fix does work!

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

Successfully merging this pull request may close these issues.

Race condition between RTSP server and the PAUSE command causing a crash.
2 participants