Skip to content

Commit 6b225fb

Browse files
jingxu.zmmxpv
authored andcommitted
monitor_notify_by_pid may be blocked by send msg to channel because bounded channel is full(but monitor lock has not be freed), on the other hand,monitor_unsubscribe may block because monitor lock is holded by the monitor_notify_by_pid
1 parent e69120e commit 6b225fb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

crates/shim/src/asynchronous/monitor.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::collections::HashMap;
1919
use lazy_static::lazy_static;
2020
use log::error;
2121
use tokio::sync::{
22-
mpsc::{channel, Receiver, Sender},
22+
mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
2323
Mutex,
2424
};
2525

@@ -68,17 +68,17 @@ pub struct Monitor {
6868

6969
pub(crate) struct Subscriber {
7070
pub(crate) topic: Topic,
71-
pub(crate) tx: Sender<ExitEvent>,
71+
pub(crate) tx: UnboundedSender<ExitEvent>,
7272
}
7373

7474
pub struct Subscription {
7575
pub id: i64,
76-
pub rx: Receiver<ExitEvent>,
76+
pub rx: UnboundedReceiver<ExitEvent>,
7777
}
7878

7979
impl Monitor {
8080
pub fn subscribe(&mut self, topic: Topic) -> Result<Subscription> {
81-
let (tx, rx) = channel::<ExitEvent>(128);
81+
let (tx, rx) = unbounded_channel::<ExitEvent>();
8282
let id = self.seq_id;
8383
self.seq_id += 1;
8484
let subscriber = Subscriber {
@@ -120,7 +120,6 @@ impl Monitor {
120120
subject: subject.clone(),
121121
exit_code,
122122
})
123-
.await
124123
.map_err(other_error!(e, "failed to send exit code"));
125124
results.push(res);
126125
}

0 commit comments

Comments
 (0)