xref: /netbsd-src/share/man/man9/accf_http.9 (revision 01869ca4d24a86379a68731bf9706a9f0820fe4e)
1.\" $NetBSD: accf_http.9,v 1.8 2017/07/03 21:28:48 wiz Exp $
2.\"
3.\" Copyright (c) 2000 Alfred Perlstein
4.\"
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26.\"
27.\" $FreeBSD: src/share/man/man9/accf_http.9,v 1.11 2005/01/18 20:52:51 ru Exp $
28.\" "
29.Dd September 4, 2008
30.Dt ACCF_HTTP 9
31.Os
32.Sh NAME
33.Nm accf_http
34.Nd "buffer incoming connections until a certain complete HTTP requests arrive"
35.Sh SYNOPSIS
36.Cd "options INET"
37.Cd "pseudo-device accf_http"
38.Sh DESCRIPTION
39This is a filter to be placed on a socket that will be using
40.Fn accept
41to receive incoming HTTP connections.
42.Pp
43Once installed on a listening socket, this filter is activated when a
44connection becomes ready to receive data (at which point
45.Xr accept 2
46would usually return the connected descriptor to the application).
47The filter prevents the descriptor from being returned immediately
48to the application via
49.Xr accept 2 .
50The descriptor is made available to the application via
51.Xr accept 2
52only when one of the following conditions is met:
53.Bl -enum
54.It
55A complete, syntactically valid HTTP/1.0 or HTTP/1.1 HEAD or GET request has
56been buffered by the kernel.
57.It
58The data buffered by the kernel cannot be part of a complete, syntactically
59valid HTTP 1.0 or HTTP/1.1 HEAD or GET request.
60.El
61.Pp
62The utility of
63.Nm
64is that a server will not have to context switch several times
65before performing the initial parsing of the request.
66This effectively reduces the amount of required CPU utilization
67to handle incoming requests by keeping active
68processes in preforking servers such as Apache low
69and reducing the size of the file descriptor set that needs
70to be managed by interfaces such as
71.Fn select ,
72.Fn poll
73or
74.Fn kevent
75based servers.
76.Sh EXAMPLES
77If the accf_data accept filter is present in the kernel configuration,
78this will enable the http accept filter
79on the socket
80.Fa sok .
81.Bd -literal -offset 0i
82	struct accept_filter_arg afa;
83
84	bzero(&afa, sizeof(afa));
85	strcpy(afa.af_name, "httpready");
86	setsockopt(sok, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa));
87.Ed
88.Sh SEE ALSO
89.Xr setsockopt 2 ,
90.Xr accept_filter 9
91.Sh HISTORY
92The accept filter mechanism and the
93.Nm
94filter were introduced in
95.Fx 4.0 .
96They were ported to
97.Nx
98by Coyote Point Systems and appeared in
99.Nx 5.0 .
100.Sh AUTHORS
101This manual page and the filter were written by
102.An Alfred Perlstein .
103