some minor bug fixs (#41)

* fix joinset leak; 

* fix udp packet format

* fix trace log panic

* avoid waiting after listener accept
This commit is contained in:
Sijie.Sun
2024-03-24 22:21:47 +08:00
committed by GitHub
parent 0f6f553010
commit ce889e990e
6 changed files with 186 additions and 49 deletions
+14 -1
View File
@@ -99,7 +99,7 @@ pub enum PacketType {
TaRpc = 6,
}
#[derive(Archive, Deserialize, Serialize, Debug)]
#[derive(Archive, Deserialize, Serialize)]
#[archive(compare(PartialEq), check_bytes)]
// Derives can be passed through to the generated type:
pub struct Packet {
@@ -109,6 +109,19 @@ pub struct Packet {
pub payload: String,
}
impl std::fmt::Debug for Packet {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"Packet {{ from_peer: {}, to_peer: {}, packet_type: {:?}, payload: {:?} }}",
self.from_peer,
self.to_peer,
self.packet_type,
&self.payload.as_bytes()
)
}
}
impl std::fmt::Debug for ArchivedPacket {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(