Merge branch 'xMAC94x/small-fixes' into 'master'

apparently span doesnt work for async, so i replaced it by an instrument version

See merge request veloren/veloren!1438
This commit is contained in:
Marcel 2020-10-14 16:30:16 +00:00
commit 5bcfb6bd0a

View File

@ -762,28 +762,28 @@ impl BParticipant {
from_remote: bool,
#[cfg(feature = "metrics")] frames_out_total_cache: &mut MultiCidFrameCache,
) {
let span = span!(Level::INFO, "delete_stream", ?sid, ?from_remote);
let _enter = span.enter();
//This needs to first stop clients from sending any more.
//Then it will wait for all pending messages (in prio) to be send to the
// protocol After this happened the stream is closed
//Only after all messages are send to the protocol, we can send the CloseStream
// frame! If we would send it before, all followup messages couldn't
// be handled at the remote side.
async {
trace!("Stopping api to use this stream");
match self.streams.read().await.get(&sid) {
Some(si) => {
si.send_closed.store(true, Ordering::Relaxed);
si.b2a_msg_recv_s.lock().await.close_channel();
},
None => {
trace!("Couldn't find the stream, might be simultaneous close from local/remote")
},
None => trace!(
"Couldn't find the stream, might be simultaneous close from local/remote"
),
}
if !from_remote {
trace!("Wait for stream to be flushed");
let (s2b_stream_finished_closed_s, s2b_stream_finished_closed_r) = oneshot::channel();
let (s2b_stream_finished_closed_s, s2b_stream_finished_closed_r) =
oneshot::channel();
b2p_notify_empty_stream_s
.expect("needs to be set when from_remote is false")
.send((sid, s2b_stream_finished_closed_s))
@ -810,6 +810,9 @@ impl BParticipant {
.await;
}
}
.instrument(tracing::info_span!("close", ?sid, ?from_remote))
.await;
}
async fn create_stream(
&self,