Skip to content

Commit

Permalink
Avoid map(await { }
Browse files Browse the repository at this point in the history
The result of the map was not awaited.
  • Loading branch information
lu-zero committed Dec 30, 2024
1 parent 22e22de commit 17ca97d
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/bin/mdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,26 @@ impl Opt {
mdev::stream::uevents()?
.for_each(|ev| async {
info!("event {:?}", ev);
let result = ev.map(|ev| async {
let result =
react_to_event(&ev.devpath, &ev.env, ev.action, conf, &self.devpath)
.await;
if let Some(rebroadcast_sender) = &rebroadcast_sender {
if rebroadcast_sender
.send(RebroadcastMessage::Event(ev))
.await
.is_err()

match ev {
Ok(ev) => {
if let Err(e) =
react_to_event(&ev.devpath, &ev.env, ev.action, conf, &self.devpath)
.await
{
panic!("rebroadcaster channel is closed");
warn!("{e}");
}
if let Some(rebroadcast_sender) = &rebroadcast_sender {
if rebroadcast_sender
.send(RebroadcastMessage::Event(ev))
.await
.is_err()
{
warn!("rebroadcaster channel is closed");
}
}
}
result
});
if let Err(e) = result {
warn!("{}", e);
Err(e) => warn!("{}", e),
}
})
.await;
Expand Down

0 comments on commit 17ca97d

Please sign in to comment.