riker-rs / riker

Easily build efficient, highly concurrent and resilient applications. An Actor Framework for Rust.
https://riker.rs
MIT License
1.02k stars 69 forks source link

Use of std::sync::Mutex in run_mailbox #73

Closed mrjoe7 closed 5 years ago

mrjoe7 commented 5 years ago

I was looking into mailbox code and nocited that std::sync::Mutex is used in run_mailbox which is called from async block at kernel.rs:73.

std::sync::Mutex should not be used in an asynchronous environment, because a mutex acquisition can block an entire reactor. Instead a futures::lock::Mutex should be used there to make sure the code won't block an executor.

leenozara commented 5 years ago

Nice spot! Did you want to try to fork, change to futures::lock::Mutex yourself and create a PR?

mrjoe7 commented 5 years ago

I might try to update the code when I have some free time.

mrjoe7 commented 5 years ago

I spent some time looking into the code and did not find any .await boundary crossing mutex locks. Now I believe there are no deadlocks possible in the current code.