Skip to content

Commit

Permalink
fix warn
Browse files Browse the repository at this point in the history
  • Loading branch information
giangndm committed Jan 8, 2024
1 parent 95ab880 commit 2a7a324
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions packages/services/virtual_socket/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ impl<BE, HE> ConnectionHandler<BE, HE> for VirtualSocketHandler {

/// Called when an event occurs on the connection.
fn on_event(&mut self, _ctx: &ConnectionContext, _now_ms: u64, event: ConnectionEvent) {
match event {
ConnectionEvent::Msg(msg) => {
self.internal.on_incomming(msg);
}
_ => {}
if let ConnectionEvent::Msg(msg) = event {
self.internal.on_incomming(msg);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/services/virtual_socket/src/vnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ impl VirtualNet {
}

pub fn create_udp_socket(&self, port: u16, buffer_size: usize) -> Result<VirtualUdpSocket, VirtualNetError> {
Ok(VirtualUdpSocket::new(self.internal.clone(), port, buffer_size)?)
VirtualUdpSocket::new(self.internal.clone(), port, buffer_size)
}
}
2 changes: 1 addition & 1 deletion packages/services/virtual_socket/src/vnet/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl VirtualNetInternal {
pub fn unregister_socket(&self, port: u16) {
let mut sockets = self.sockets.write();
let mut ports = self.ports.write();
if let Some(_) = sockets.remove(&port) {
if sockets.remove(&port).is_some() {
log::info!("[VirtualNetInternal] Unregister socket on port {}", port);
ports.push(port);
}

Check warning on line 62 in packages/services/virtual_socket/src/vnet/internal.rs

View check run for this annotation

Codecov / codecov/patch

packages/services/virtual_socket/src/vnet/internal.rs#L62

Added line #L62 was not covered by tests
Expand Down
4 changes: 2 additions & 2 deletions packages/transports/udp/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ impl UdpTransport {
if let Ok((size, addr)) = async_socket.recv_from(&mut buf).await {
let current_ms = timer.now_ms();
if let Some(msg_tx) = connection.get_mut(&addr) {
msg_tx.0.try_send((buf, size));
let _ = msg_tx.0.try_send((buf, size));
msg_tx.1 = current_ms;
} else {
log::info!("[UdpTransport] on new connection from {}", addr);
conn_id_seed += 1;
let conn_id = ConnId::from_in(UDP_PROTOCOL_ID, conn_id_seed);
let (msg_tx, msg_rx) = async_std::channel::bounded(1024);
msg_tx.try_send((buf, size));
let _ = msg_tx.try_send((buf, size));
connection.insert(addr, (msg_tx, current_ms));
let socket = socket.clone();
let async_socket = async_socket.clone();
Expand Down

0 comments on commit 2a7a324

Please sign in to comment.