Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107157230
D31821.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D31821.diff
View Options
diff --git a/lib/libc/sys/listen.2 b/lib/libc/sys/listen.2
--- a/lib/libc/sys/listen.2
+++ b/lib/libc/sys/listen.2
@@ -28,7 +28,7 @@
.\" From: @(#)listen.2 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
-.Dd April 14, 2020
+.Dd October 11, 2022
.Dt LISTEN 2
.Os
.Sh NAME
@@ -106,10 +106,13 @@
.Fa backlog ;
if a value greater than
.Va kern.ipc.soacceptqueue
-or less than zero is specified,
+is specified,
.Fa backlog
is silently forced to
.Va kern.ipc.soacceptqueue .
+If a negative value is used,
+.Fa backlog
+is silently forced to 0.
.Pp
If the listen queue overflows, the kernel will emit a LOG_DEBUG syslog message.
The
@@ -191,3 +194,8 @@
is still available but hidden from a
.Xr sysctl 3
-a output so that existing applications and scripts continue to work.
+To improve POSIX compliance, a negative
+.Fa backlog
+argument is handled the same as 0.
+This was introduced in
+.Fx 14.0 .
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1075,7 +1075,9 @@
so->so_options |= SO_ACCEPTCONN;
listening:
- if (backlog < 0 || backlog > somaxconn)
+ if (backlog < 0)
+ backlog = 0;
+ if (backlog > somaxconn)
backlog = somaxconn;
so->sol_qlimit = backlog;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 12, 12:11 AM (20 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15759176
Default Alt Text
D31821.diff (1 KB)
Attached To
Mode
D31821: Improve POSIX compliance of listen()
Attached
Detach File
Event Timeline
Log In to Comment