Skip to content

Commit c9c143c

Browse files
committed
don't enable REUSEPORT when listening on unix socket
1 parent bab4296 commit c9c143c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/httpz.zig

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,13 @@ pub fn Server(comptime H: type) type {
381381
}
382382

383383
try posix.setsockopt(listener, posix.SOL.SOCKET, posix.SO.REUSEADDR, &std.mem.toBytes(@as(c_int, 1)));
384-
if (@hasDecl(posix.SO, "REUSEPORT_LB")) {
385-
try posix.setsockopt(listener, posix.SOL.SOCKET, posix.SO.REUSEPORT_LB, &std.mem.toBytes(@as(c_int, 1)));
386-
} else if (@hasDecl(posix.SO, "REUSEPORT")) {
387-
try posix.setsockopt(listener, posix.SOL.SOCKET, posix.SO.REUSEPORT, &std.mem.toBytes(@as(c_int, 1)));
384+
385+
if (config.unix_path == null) {
386+
if (@hasDecl(posix.SO, "REUSEPORT_LB")) {
387+
try posix.setsockopt(listener, posix.SOL.SOCKET, posix.SO.REUSEPORT_LB, &std.mem.toBytes(@as(c_int, 1)));
388+
} else if (@hasDecl(posix.SO, "REUSEPORT")) {
389+
try posix.setsockopt(listener, posix.SOL.SOCKET, posix.SO.REUSEPORT, &std.mem.toBytes(@as(c_int, 1)));
390+
}
388391
}
389392

390393
{

0 commit comments

Comments
 (0)