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 a dedicated method for disconnecting TLS connections #10005

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

Commits on Nov 13, 2024

  1. AsioTlsStream: inherit from SharedObject

    All usages of `AsioTlsStream` were already using `Shared<AsioTlsStream>` to
    keep a reference-counted instance. This commit moves the reference counting to
    `AsioTlsStream` itself by inheriting from `SharedObject`. This will allow to
    implement methods making use of the fact that these objects are
    reference-counted.
    
    The changes outside of `lib/base/tlsstream.hpp` are merely replacing
    `Shared<AsioTlsStream>::Ptr` with `AsioTlsStream::Ptr` everywhere.
    julianbrost committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    a85c188 View commit details
    Browse the repository at this point in the history

Commits on Nov 14, 2024

  1. AsioTlsStream: add GracefulDisconnect() and ForceDisconnect()

    Calling `AsioTlsStream::async_shutdown()` performs a TLS shutdown which
    exchanges messages (that's why it takes a `yield_context`) and thus has the
    potential to block the coroutine. Therefore, it should be protected with a
    timeout. As `async_shutdown()` doesn't simply take a timeout, this has to be
    implemented using a timer. So far, these timers are scattered throughout the
    codebase with some places missing them entirely. This commit adds helper
    functions to properly shutdown a TLS connection with a single function call.
    julianbrost committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    3e29c8e View commit details
    Browse the repository at this point in the history
  2. JsonRpcConnection: use AsioTlsStream::GracefulDisconnect()

    This new helper functions allows deduplicating the timeout handling for
    `async_shutdown()`.
    julianbrost committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    7784bef View commit details
    Browse the repository at this point in the history
  3. HttpServerConnection: use AsioTlsStream::GracefulDisconnect()

    This new helper function has proper timeout handling which was missing here.
    julianbrost committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    be5151a View commit details
    Browse the repository at this point in the history
  4. Add comment for remaining uses of async_shutdown() why it's safe

    The reason for introducing AsioTlsStream::GracefulDisconnect() was to handle
    the TLS shutdown properly with a timeout since it involves a timeout. However,
    the implementation of this timeout involves spwaning coroutines which are
    redundant in some cases. This commit adds comments to the remaining calls of
    async_shutdown() stating why calling it is safe in these places.
    julianbrost committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    7430618 View commit details
    Browse the repository at this point in the history