Skip to content

Commit

Permalink
fix API return value
Browse files Browse the repository at this point in the history
  • Loading branch information
ibigbug committed Sep 10, 2024
1 parent 8c1380f commit 450da0c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions crates/shadowsocks/src/relay/udprelay/proxy_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl ProxySocket {
send_buf.len()
);

let send_len = send_buf.len();
let n_sent = payload.len();

let send_fn = || async {
let mut socket = self.socket_w.lock().await;
Expand All @@ -339,7 +339,7 @@ impl ProxySocket {
},
};

Ok(send_len)
Ok(n_sent)
}

/// poll family functions
Expand Down Expand Up @@ -375,7 +375,7 @@ impl ProxySocket {
send_buf.len()
);

let n_send_buf = send_buf.len();
let n_sent = payload.len();

let mut io = self
.socket_w
Expand All @@ -389,7 +389,7 @@ impl ProxySocket {
})?;
ready!(io.poll_flush_unpin(cx)?);

Poll::Ready(Ok(n_send_buf))
Poll::Ready(Ok(n_sent))
}

/// poll family functions
Expand Down Expand Up @@ -431,7 +431,7 @@ impl ProxySocket {
send_buf.len()
);

let n_send_buf = send_buf.len();
let n_sent = payload.len();
let mut io = self
.socket_w
.try_lock()
Expand All @@ -443,7 +443,7 @@ impl ProxySocket {
dst: Some(target),
})?;
ready!(io.poll_flush_unpin(cx)?);
Poll::Ready(Ok(n_send_buf))
Poll::Ready(Ok(n_sent))
}

/// poll family functions
Expand Down Expand Up @@ -483,7 +483,8 @@ impl ProxySocket {
send_buf.len()
);

let send_len = send_buf.len();
// we should not use `send_buf.len()` here, because `send_buf` may contain more data than `payload`
let n_sent = payload.len();

let send_fn = || async {
let mut socket = self.socket_w.lock().await;
Expand All @@ -505,7 +506,7 @@ impl ProxySocket {
},
};

Ok(send_len)
Ok(n_sent)
}

fn decrypt_recv_buffer(
Expand Down

0 comments on commit 450da0c

Please sign in to comment.