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

Fix potential race condition during disconnection #2719

Merged

Commits on Apr 21, 2023

  1. Fix potential race condition during disconnection

    When the disconnect() function is called twice in parallel it is possible that
    one thread deletes the self._sock reference, while the other thread will
    attempt to call .close() on it, leading to an AttributeError.
    
    This situation can routinely be encountered by closing the connection in a
    PubSubWorkerThread error handler in a blocking thread (ie. with
    sleep_time==None), and then calling .close() on the PubSub object.
    The main thread will then run into the disconnect() function, and the listener
    thread is woken up by the closure and will race into the disconnect()
    function, too.
    
    This can be fixed easily by copying the object reference before doing the
    None-check, similar to what we do in the redis.client.close() function.
    Anthchirp committed Apr 21, 2023
    Configuration menu
    Copy the full SHA
    3053abc View commit details
    Browse the repository at this point in the history