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

Use an async-aware Mutex implementation #664

Merged
merged 1 commit into from
Aug 14, 2023
Merged

Use an async-aware Mutex implementation #664

merged 1 commit into from
Aug 14, 2023

Conversation

imobachgs
Copy link
Contributor

@imobachgs imobachgs commented Jul 13, 2023

Clippy reports that in our code we call await while holding a lock. Example:

warning: this `MutexGuard` is held across an `await` point
   --> agama-dbus-server/src/network/dbus/tree.rs:145:13
    |
145 |         let mut objects = self.objects.lock();
    |             ^^^^^^^^^^^
    |
    = help: consider using an async-aware `Mutex` type or ensuring the `MutexGuard` is dropped before calling await
note: these are all the `await` points this lock is held through
   --> agama-dbus-server/src/network/dbus/tree.rs:145:9
    |
145 | /         let mut objects = self.objects.lock();
146 | |         for path in objects.connections.values() {
147 | |             self.remove_connection_on(path.as_str()).await?;
148 | |         }
149 | |         objects.connections.clear();
150 | |         Ok(())
151 | |     }
    | |_____^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_lock

There are two possible solutions:

This PR replaces parking_lot Mutex with the one included in the futures. Both of them are already included as dependencies of other crates.

Follow-up: #703.

@imobachgs imobachgs changed the title Use an async-aware Mutex implementation [REFC] Use an async-aware Mutex implementation Jul 13, 2023
@coveralls
Copy link

Coverage Status

coverage: 72.385% (+0.002%) from 72.383% when pulling 0dbb5f9 on imobachgs:async-aware-mutex into 2e11beb on openSUSE:master.

@imobachgs imobachgs changed the title [REFC] Use an async-aware Mutex implementation [RFC] Use an async-aware Mutex implementation Jul 13, 2023
@imobachgs imobachgs changed the title [RFC] Use an async-aware Mutex implementation Use an async-aware Mutex implementation Aug 12, 2023
@imobachgs imobachgs marked this pull request as ready for review August 12, 2023 11:31
@imobachgs imobachgs merged commit f86969b into agama-project:master Aug 14, 2023
10 checks passed
@imobachgs imobachgs deleted the async-aware-mutex branch August 14, 2023 12:35
@imobachgs imobachgs mentioned this pull request Sep 26, 2023
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.

3 participants