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

Remove lock from sessionWS.SendBytes #1140

Merged
merged 2 commits into from
Jan 24, 2024

Commits on Nov 14, 2023

  1. Remove lock from sessionWS.SendBytes

    There are six different calls to s.Lock() in sessionWS.  Three of these locks are around calls to SetWriteDeadline and WriteMessage on the WebSocket.  WriteMessage will block for up to the timeout set in SetWriteDeadline, which has a default of 5000 milliseconds.  This lock is also acquired by SendBytes to determine if the session has been stopped.  This is a problem as the event processing methods in StatusRegistry and Track call SendBytes directly on the Session.  If one of the Sessions being written to has delays in writing data, this could cause backups in the event processing.
    
    The simplest approach (this commit) is to just remove the lock within SendBytes.  To avoid a race condition with writing to a closed channel, we need to not close the outgoingCh channel in the Close method.  This is safe to do as channels do not need to be explicitly closed and will automatically be cleaned up by the garbage collector.  It should also be possible to remove the lock entirely from sessionWS, but that is a much larger change.
    joshgarnett committed Nov 14, 2023
    Configuration menu
    Copy the full SHA
    f422a27 View commit details
    Browse the repository at this point in the history

Commits on Jan 19, 2024

  1. Configuration menu
    Copy the full SHA
    62730e8 View commit details
    Browse the repository at this point in the history