mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-05 23:51:08 +00:00
Don't hold the lock while yielding back to the executor in Client
This commit is contained in:
parent
d6d1e20f07
commit
0b79950510
1 changed files with 7 additions and 4 deletions
|
@ -835,11 +835,14 @@ impl Client {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(handler) = state.message_handlers.get(&payload_type_id).cloned()
|
let handler = state.message_handlers.get(&payload_type_id).cloned();
|
||||||
{
|
// Dropping the state prevents deadlocks if the handler interacts with rpc::Client.
|
||||||
drop(state); // Avoid deadlocks if the handler interacts with rpc::Client
|
// It also ensures we don't hold the lock while yielding back to the executor, as
|
||||||
let future = handler(model, message, &this, cx.clone());
|
// that might cause the executor thread driving this future to block indefinitely.
|
||||||
|
drop(state);
|
||||||
|
|
||||||
|
if let Some(handler) = handler {
|
||||||
|
let future = handler(model, message, &this, cx.clone());
|
||||||
let client_id = this.id;
|
let client_id = this.id;
|
||||||
log::debug!(
|
log::debug!(
|
||||||
"rpc message received. client_id:{}, message_id:{}, sender_id:{:?}, type:{}",
|
"rpc message received. client_id:{}, message_id:{}, sender_id:{:?}, type:{}",
|
||||||
|
|
Loading…
Reference in a new issue