Browse Source

Add option to enable TCP_DEFER_ACCEPT (fixes #1447)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2479 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.23
Stefan Bühler 13 years ago
parent
commit
0226d4bf36
  1. 1
      NEWS
  2. 6
      doc/configuration.txt
  3. 1
      src/base.h
  4. 3
      src/configfile.c
  5. 17
      src/network.c

1
NEWS

@ -27,6 +27,7 @@ NEWS
* Change name/version separator back to "/" (affects every place where the version is printed)
* Fix bug with FastCGI request id overflow under high load; just use always id 1 as we don't use multiplexing. (thx jgray)
* Add some dirlisting enhancements (fixes #1458)
* Add option to enable TCP_DEFER_ACCEPT (fixes #1447)
- 1.4.22 - 2009-03-07
* Fix wrong lua type for CACHE_MISS/CACHE_HIT in mod_cml (fixes #533)

6
doc/configuration.txt

@ -281,6 +281,12 @@ server.port
server.use-ipv6
bind to the IPv6 socket
server.defer-accept
set TCP_DEFER_ACCEPT to the specified value on the socket if the value is > 0
and TCP_DEFER_ACCEPT is available on the platform (linux2.4+)
default: 0
server.tag
set the string returned by the Server: response header

1
src/base.h

@ -274,6 +274,7 @@ typedef struct {
unsigned short ssl_use_sslv2;
unsigned short use_ipv6;
unsigned short defer_accept;
unsigned short is_ssl;
unsigned short allow_http11;
unsigned short etag_use_inode;

3
src/configfile.c

@ -96,6 +96,7 @@ static int config_insert(server *srv) {
{ "etag.use-size", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 51 */
{ "server.reject-expect-100-with-417", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 52 */
{ "debug.log-timeouts", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_CONNECTION }, /* 53 */
{ "server.defer-accept", NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION }, /* 54 */
{ "server.host", "use server.bind instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
{ "server.docroot", "use server.document-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
{ "server.virtual-root", "load mod_simple_vhost and use simple-vhost.server-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET },
@ -164,6 +165,7 @@ static int config_insert(server *srv) {
s->is_ssl = 0;
s->ssl_use_sslv2 = 0;
s->use_ipv6 = 0;
s->defer_accept = 0;
#ifdef HAVE_LSTAT
s->follow_symlink = 1;
#endif
@ -182,6 +184,7 @@ static int config_insert(server *srv) {
cv[7].destination = s->server_tag;
cv[8].destination = &(s->use_ipv6);
cv[54].destination = &(s->defer_accept);
/* 13 max-worker */

17
src/network.c

@ -73,10 +73,6 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
int is_unix_domain_socket = 0;
int fd;
#ifdef SO_ACCEPTFILTER
struct accept_filter_arg afa;
#endif
#ifdef __WIN32
WORD wVersionRequested;
WSADATA wsaData;
@ -395,13 +391,18 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
"ssl requested but openssl support is not compiled in");
return -1;
#endif
#ifdef TCP_DEFER_ACCEPT
} else if (s->defer_accept) {
int v = s->defer_accept;
if (-1 == setsockopt(srv_socket->fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &v, sizeof(v))) {
log_error_write(srv, __FILE__, __LINE__, "ss", "can't set TCP_DEFER_ACCEPT: ", strerror(errno));
}
#endif
} else {
#ifdef SO_ACCEPTFILTER
/*
* FreeBSD accf_http filter
*
*/
/* FreeBSD accf_http filter */
struct accept_filter_arg afa;
memset(&afa, 0, sizeof(afa));
strcpy(afa.af_name, "httpready");
if (setsockopt(srv_socket->fd, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa)) < 0) {

Loading…
Cancel
Save