diff --git a/vnt/src/channel/context.rs b/vnt/src/channel/context.rs index 3a038b3..72bb564 100644 --- a/vnt/src/channel/context.rs +++ b/vnt/src/channel/context.rs @@ -289,15 +289,7 @@ impl ContextInner { } } pub fn remove_route(&self, ip: &Ipv4Addr, route_key: RouteKey) { - if self.route_table.remove_route(ip, route_key) { - if route_key.is_tcp { - if let Some(tcp) = self.tcp_map.write().remove(&route_key.addr) { - if let Err(e) = tcp.shutdown() { - log::warn!("{:?}", e); - } - } - } - } + self.route_table.remove_route(ip, route_key) } } @@ -501,18 +493,13 @@ impl RouteTable { } list } - pub fn remove_route(&self, id: &Ipv4Addr, route_key: RouteKey) -> bool { + pub fn remove_route(&self, id: &Ipv4Addr, route_key: RouteKey) { let mut write_guard = self.route_table.write(); if let Some((_, routes)) = write_guard.get_mut(id) { routes.retain(|(x, _)| x.route_key() != route_key); if routes.is_empty() { write_guard.remove(id); - true - } else { - false } - } else { - return true; } } /// 更新路由入栈包的时刻,长时间没有收到数据的路由将会被剔除 diff --git a/vnt/src/channel/mod.rs b/vnt/src/channel/mod.rs index ebc6cf8..c524290 100644 --- a/vnt/src/channel/mod.rs +++ b/vnt/src/channel/mod.rs @@ -179,9 +179,6 @@ pub fn init_context( ) }; - io_convert(socket.set_reuse_address(true), |_| { - format!("set_reuse_address failed: {}", &address) - })?; io_convert(socket.set_send_buffer_size(2 * 1024 * 1024), |_| { format!("set_send_buffer_size failed: {}", &address) })?; @@ -220,9 +217,6 @@ pub fn init_context( (socket, address) }; - io_convert(socket.set_reuse_address(true), |_| { - format!("set_reuse_address failed: {}", &address) - })?; if let Err(e) = socket.bind(&address.into()) { if ports[0] == 0 { //端口可能冲突,则使用任意端口