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 EventCallback #7251

Merged
merged 2 commits into from
Dec 2, 2024
Merged

Remove EventCallback #7251

merged 2 commits into from
Dec 2, 2024

Conversation

Serock3
Copy link
Contributor

@Serock3 Serock3 commented Nov 28, 2024

The event callback was a dynamically typed async closure, which resulted in verbose type bounds. I replaced it with a simple concrete type, as there was only ever a single instance of it anyway.


This change is Reviewable

@Serock3 Serock3 self-assigned this Nov 28, 2024
@Serock3 Serock3 changed the title Remove-event-callback Remove EventCallback Nov 28, 2024
@Serock3 Serock3 marked this pull request as ready for review November 28, 2024 10:53
@Serock3 Serock3 requested a review from hulthe November 28, 2024 11:02
@Serock3 Serock3 force-pushed the remove-event-callback branch 7 times, most recently from 3990330 to cf3089f Compare November 28, 2024 14:03
Copy link
Contributor

@hulthe hulthe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 5 files at r2.
Reviewable status: 1 of 5 files reviewed, all discussions resolved


talpid-openvpn/src/lib.rs line 305 at r2 (raw file):

            openvpn_init_args,
            event_server::OpenvpnEventProxyImpl {
                event_hook: tokio::sync::Mutex::new(event_hook),

If you use tokios mpsc-channels you won't need to wrap this in a Mutex

@hulthe hulthe added the Daemon Issues related to mullvad-daemon label Nov 28, 2024
Copy link
Contributor Author

@Serock3 Serock3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 5 files reviewed, all discussions resolved (waiting on @hulthe)


talpid-openvpn/src/lib.rs line 305 at r2 (raw file):

Previously, hulthe (Joakim Hulthe) wrote…

If you use tokios mpsc-channels you won't need to wrap this in a Mutex

I opted to simply clone the event_hook on each call for simplicity. I assume that is quite cheep to do, although the neither the docs for tokio or futures mpsc mention anything about the cost.

Copy link
Contributor

@hulthe hulthe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💰

Reviewed 2 of 5 files at r2, 1 of 1 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved


talpid-openvpn/src/lib.rs line 305 at r2 (raw file):

Previously, Serock3 (Sebastian Holmin) wrote…

I opted to simply clone the event_hook on each call for simplicity. I assume that is quite cheep to do, although the neither the docs for tokio or futures mpsc mention anything about the cost.

It's holding an Arc internally, so the cost is just Cloning that.

I personally still would prefer using tokios channel and avoiding the clones, but I won't make a fuss of it :)

@Serock3 Serock3 force-pushed the remove-event-callback branch from cf3089f to 6960dae Compare December 2, 2024 09:41
@Serock3 Serock3 force-pushed the remove-event-callback branch from 6960dae to ca17aee Compare December 2, 2024 12:39
@Serock3 Serock3 merged commit 3ed024c into main Dec 2, 2024
52 of 53 checks passed
@Serock3 Serock3 deleted the remove-event-callback branch December 2, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Daemon Issues related to mullvad-daemon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants