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

Make close_gracefully public #129

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

jagerman
Copy link
Member

@jagerman jagerman commented May 9, 2024

libsession-util ran into an issue where the quic::Network destruction segfaults because it has callbacks (e.g. connection closing) that expect to be able to use their local quic::Network instance, but can't because it's in the process of being destroyed.

Essentially the pattern is this:

class A {
    quic::Network net;
};
A a;
// start a connection with a connection_close callback that
// references `a`.

If the quic::Network destruction is triggered by the destruction of a, then the quic::Network destructor is firing after a is no longer in a valid state, and so the callback referencing a is invalid.

Exposing close_gracefully() allows the application to deal with this: it can add a net.close_gracefully() either in A's destructor or some other shutdown code so that it can ensure the quic Network shutdown happens before a becomes unusable.

libsession-util ran into an issue where the quic::Network destruction
segfaults because it has callbacks (e.g. connection closing) that expect
to be able to use their local `quic::Network` instance, but can't
because it's in the process of being destroyed.

Essentially the pattern is this:

    class A {
        quic::Network net;
    };
    A a;
    // start a connection with a connection_close callback that
    // references `a`.

If the quic::Network destruction is triggered by the destruction of `a`,
then the quic::Network destructor is firing *after* `a` is no longer in
a valid state, and so the callback referencing `a` is invalid.

Exposing close_gracefully() allows the application to deal with this: it
can add a `net.close_gracefully()` either in `A`'s destructor or some
other shutdown code so that it can ensure the quic Network shutdown
happens *before* `a` becomes unusable.
@jagerman jagerman marked this pull request as draft May 27, 2024 18:41
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