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

monitor_notify_by_pid and monitor_unsubscribe may cause dead lock #270

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions crates/shim/src/asynchronous/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::collections::HashMap;
use lazy_static::lazy_static;
use log::error;
use tokio::sync::{
mpsc::{channel, Receiver, Sender},
mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
Mutex,
};

Expand Down Expand Up @@ -68,17 +68,17 @@ pub struct Monitor {

pub(crate) struct Subscriber {
pub(crate) topic: Topic,
pub(crate) tx: Sender<ExitEvent>,
pub(crate) tx: UnboundedSender<ExitEvent>,
}

pub struct Subscription {
pub id: i64,
pub rx: Receiver<ExitEvent>,
pub rx: UnboundedReceiver<ExitEvent>,
}

impl Monitor {
pub fn subscribe(&mut self, topic: Topic) -> Result<Subscription> {
let (tx, rx) = channel::<ExitEvent>(128);
let (tx, rx) = unbounded_channel::<ExitEvent>();
let id = self.seq_id;
self.seq_id += 1;
let subscriber = Subscriber {
Expand Down Expand Up @@ -120,7 +120,6 @@ impl Monitor {
subject: subject.clone(),
exit_code,
})
.await
.map_err(other_error!(e, "failed to send exit code"));
results.push(res);
}
Expand Down
Loading