Skip to content

Commit d69c964

Browse files
committed
Refuse SO_REUSEPORT on illumos and Solaris instead of failing to compile
1 parent 9447195 commit d69c964

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • pingora-core/src/listeners

pingora-core/src/listeners/l4.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,22 @@ fn apply_tcp_socket_options(sock: &TcpSocket, opt: Option<&TcpSocketOptions>) ->
193193
.or_err(BindError, "failed to set IPV6_V6ONLY")?;
194194
}
195195

196-
#[cfg(unix)]
196+
#[cfg(all(unix, not(any(target_os = "illumos", target_os = "solaris"))))]
197197
if let Some(reuseport) = opt.so_reuseport {
198198
socket_ref
199199
.set_reuse_port(reuseport)
200200
.or_err(BindError, "failed to set SO_REUSEPORT")?;
201201
}
202202

203+
// illumos and Solaris have no SO_REUSEPORT; refuse rather than ignore the request.
204+
#[cfg(any(target_os = "illumos", target_os = "solaris"))]
205+
if opt.so_reuseport.is_some() {
206+
return pingora_error::Error::e_explain(
207+
BindError,
208+
"SO_REUSEPORT is not supported on this platform",
209+
);
210+
}
211+
203212
#[cfg(unix)]
204213
let raw = sock.as_raw_fd();
205214
#[cfg(windows)]

0 commit comments

Comments
 (0)