View | Details | Raw Unified | Return to bug 194568
Collapse All | Expand All

(-)src/sys/kern/uipc_socket.c (+26 lines)
Lines 188-195 Link Here
188
 * for accept(2).
188
 * for accept(2).
189
 * NB: The orginal sysctl somaxconn is still available but hidden
189
 * NB: The orginal sysctl somaxconn is still available but hidden
190
 * to prevent confusion about the actual purpose of this number.
190
 * to prevent confusion about the actual purpose of this number.
191
 * Also allow the system administrator to set a minimum listen queue
192
 * size to adjust the behaviour of badly written programs.
191
 */
193
 */
192
static int somaxconn = SOMAXCONN;
194
static int somaxconn = SOMAXCONN;
195
static int sominconn = SOMAXCONN;
193
196
194
static int
197
static int
195
sysctl_somaxconn(SYSCTL_HANDLER_ARGS)
198
sysctl_somaxconn(SYSCTL_HANDLER_ARGS)
Lines 216-221 Link Here
216
    0, sizeof(int), sysctl_somaxconn, "I",
219
    0, sizeof(int), sysctl_somaxconn, "I",
217
    "Maximum listen socket pending connection accept queue size (compat)");
220
    "Maximum listen socket pending connection accept queue size (compat)");
218
221
222
static int
223
sysctl_sominconn(SYSCTL_HANDLER_ARGS)
224
{
225
	int error;
226
	int val;
227
228
	val = sominconn;
229
	error = sysctl_handle_int(oidp, &val, 0, req);
230
	if (error || !req->newptr )
231
		return (error);
232
233
	if (val < 1 || val > USHRT_MAX)
234
		return (EINVAL);
235
236
	sominconn = val;
237
	return (0);
238
}
239
SYSCTL_PROC(_kern_ipc, OID_AUTO, soacceptqueue_minimum, CTLTYPE_UINT | CTLFLAG_RW,
240
    0, sizeof(int), sysctl_sominconn, "I",
241
    "Minimum listen socket pending connection accept queue size");
242
219
static int numopensockets;
243
static int numopensockets;
220
SYSCTL_INT(_kern_ipc, OID_AUTO, numopensockets, CTLFLAG_RD,
244
SYSCTL_INT(_kern_ipc, OID_AUTO, numopensockets, CTLFLAG_RD,
221
    &numopensockets, 0, "Number of open sockets");
245
    &numopensockets, 0, "Number of open sockets");
Lines 661-666 Link Here
661
685
662
	if (backlog < 0 || backlog > somaxconn)
686
	if (backlog < 0 || backlog > somaxconn)
663
		backlog = somaxconn;
687
		backlog = somaxconn;
688
	if (backlog < sominconn)
689
		backlog = sominconn;
664
	so->so_qlimit = backlog;
690
	so->so_qlimit = backlog;
665
	so->so_options |= SO_ACCEPTCONN;
691
	so->so_options |= SO_ACCEPTCONN;
666
}
692
}

Return to bug 194568