Skip to content

Commit

Permalink
trigger CI to address dead lock
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Apr 28, 2021
1 parent d69a2fa commit 7b3415f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions crates/shadowsocks-service/src/server/udprelay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,10 @@ impl UdpAssociationContext {
let mut buffer = [0u8; MAXIMUM_UDP_PAYLOAD_SIZE];
loop {
let (n, addr) = match outbound.recv_from(&mut buffer).await {
Ok((n, addr)) => {
trace!("udp relay {} <- {} received {} bytes", self.peer_addr, addr, n);
Ok(r) => {
// Keep association alive in map
let _ = self.assoc_map.lock().await.get(&self.peer_addr);
(n, addr)
r
}
Err(err) => {
error!(
Expand All @@ -430,13 +429,23 @@ impl UdpAssociationContext {
}
};

trace!("udp relay {} <- {} received {} bytes", self.peer_addr, addr, n);

let data = &buffer[..n];

let target_addr = match self.target_cache.lock().await.get(&addr) {
Some(a) => a.clone(),
None => Address::from(addr),
};

trace!(
"udp relay {} <- {} ({}) with {} bytes",
self.peer_addr,
target_addr,
addr,
data.len()
);

// Send back to client
if let Err(err) = self.inbound.send_to(self.peer_addr, &target_addr, data).await {
warn!(
Expand Down

0 comments on commit 7b3415f

Please sign in to comment.