Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protocol/mdns: Use SO_REUSEPORT for the mDNS socket #68

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/protocol/mdns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ impl Mdns {
) -> crate::Result<Self> {
let socket = Socket::new(Domain::IPV4, Type::DGRAM, Some(Protocol::UDP))?;
socket.set_reuse_address(true)?;
// TODO: fix
// #[cfg(unix)]
// socket.set_reuse_port(true)?;
#[cfg(unix)]
socket.set_reuse_port(true)?;
Comment on lines +131 to +132
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dq: What was the reason this was commented out in the past with a "todo: fix"? Did something break previously?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIR when I wrote the code, I was using an incorrect version of socket2 or something which caused compilation to fail on Linux even though I had #[cfg(unix)]. Since the code worked without port_reuse(true), I just commented the code out and was planning on revisiting it in the future but never did until now.

socket.bind(
&SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), IPV4_MULTICAST_PORT).into(),
)?;
Expand Down
Loading