Skip to content

Use an async-aware Mutex implementation#664

Merged
imobachgs merged 1 commit intoagama-project:masterfrom
imobachgs:async-aware-mutex
Aug 14, 2023
Merged

Use an async-aware Mutex implementation#664
imobachgs merged 1 commit intoagama-project:masterfrom
imobachgs:async-aware-mutex

Conversation

@imobachgs
Copy link
Copy Markdown
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
Copy Markdown

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
@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