Pass can reuse to bind_socket

This commit is contained in:
Yuke Peng
2024-08-24 12:01:08 +08:00
committed by Tate, Hongliang Tian
parent dc4df47007
commit 434f143e30
5 changed files with 21 additions and 9 deletions

View File

@ -94,6 +94,7 @@ impl IfaceCommon {
let mut used_ports = self.used_ports.write();
if let Some(used_times) = used_ports.get_mut(&port) {
if *used_times == 0 || can_reuse {
// FIXME: Check if the previous socket was bound with SO_REUSEADDR.
*used_times += 1;
} else {
return_errno_with_message!(Errno::EADDRINUSE, "the address is already in use");