From 47cddae04f2e60546f8fbffbc8c3f6b4bd32cf47 Mon Sep 17 00:00:00 2001 From: occheung Date: Thu, 19 Sep 2024 17:16:18 +0800 Subject: [PATCH] runtime mgmt: avoid passing incomplete log to core_log --- src/runtime/src/mgmt.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/runtime/src/mgmt.rs b/src/runtime/src/mgmt.rs index e27b8a1..64523f6 100644 --- a/src/runtime/src/mgmt.rs +++ b/src/runtime/src/mgmt.rs @@ -234,6 +234,8 @@ mod remote_coremgmt { *guard += 1; *guard }; + let mut buffer = Vec::new(); + loop { if id != *pull_id.borrow() { // another connection attempts to pull the log... @@ -254,8 +256,12 @@ mod remote_coremgmt { .await; match reply { - Ok(Packet::CoreMgmtGetLogReply { last: _, length, data }) => { - write_chunk(stream, &data[..length as usize]).await?; + Ok(Packet::CoreMgmtGetLogReply { last, length, data }) => { + buffer.extend(&data[..length as usize]); + if last { + write_chunk(stream, &buffer).await?; + buffer.clear(); + } } Ok(packet) => { error!("received unexpected aux packet: {:?}", packet);