From 4c2fc61d64694e06b62c3a81d28e2bc183aa1be4 Mon Sep 17 00:00:00 2001 From: johannesd3 Date: Mon, 12 Apr 2021 22:54:32 +0200 Subject: [PATCH] Better joining of session tasks --- core/src/session.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/src/session.rs b/core/src/session.rs index d7e478fa..388ef391 100644 --- a/core/src/session.rs +++ b/core/src/session.rs @@ -10,7 +10,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use byteorder::{BigEndian, ByteOrder}; use bytes::Bytes; use futures_core::TryStream; -use futures_util::{FutureExt, StreamExt, TryStreamExt}; +use futures_util::{future, StreamExt, TryStreamExt}; use once_cell::sync::OnceCell; use thiserror::Error; use tokio::sync::mpsc; @@ -126,9 +126,14 @@ impl Session { .forward(sink); let receiver_task = DispatchTask(stream, session.weak()); - let task = - futures_util::future::join(sender_task, receiver_task).map(|_| io::Result::<_>::Ok(())); - tokio::spawn(task); + tokio::spawn(async move { + let result = future::try_join(sender_task, receiver_task).await; + + if let Err(e) = result { + error!("{}", e); + } + }); + session }