diff options
author | Arno Töll <arno@debian.org> | 2012-11-21 23:03:59 +0100 |
---|---|---|
committer | Arno Töll <arno@debian.org> | 2012-11-21 23:03:59 +0100 |
commit | 16cadaab87d25fc026ac777746eabbff3030f0cc (patch) | |
tree | ebd408dc2d6d5d821137994e93203e57ab8f25f6 /src/network.c | |
parent | 985230456afb0b945234dfac919a6ece3df4a715 (diff) | |
download | lighttpd-16cadaab87d25fc026ac777746eabbff3030f0cc.tar.gz |
Imported Upstream version 1.4.28upstream/1.4.28
Diffstat (limited to 'src/network.c')
-rw-r--r-- | src/network.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/network.c b/src/network.c index 4b07618..a98b4b8 100644 --- a/src/network.c +++ b/src/network.c @@ -27,15 +27,14 @@ # include <openssl/rand.h> #endif -static handler_t network_server_handle_fdevent(void *s, void *context, int revents) { - server *srv = (server *)s; +static handler_t network_server_handle_fdevent(server *srv, void *context, int revents) { server_socket *srv_socket = (server_socket *)context; connection *con; int loops = 0; UNUSED(context); - if (revents != FDEVENT_IN) { + if (0 == (revents & FDEVENT_IN)) { log_error_write(srv, __FILE__, __LINE__, "sdd", "strange event for server socket", srv_socket->fd, @@ -82,6 +81,9 @@ static int network_ssl_servername_callback(SSL *ssl, int *al, server *srv) { buffer_copy_string(con->tlsext_server_name, servername); buffer_to_lower(con->tlsext_server_name); + /* Sometimes this is still set, confusing COMP_HTTP_HOST */ + buffer_reset(con->uri.authority); + config_cond_cache_reset(srv, con); config_setup_connection(srv, con); @@ -223,7 +225,7 @@ static int network_server_init(server *srv, buffer *host_token, specific_config val = 1; if (setsockopt(srv_socket->fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) { - log_error_write(srv, __FILE__, __LINE__, "ss", "socketsockopt failed:", strerror(errno)); + log_error_write(srv, __FILE__, __LINE__, "ss", "socketsockopt(SO_REUSEADDR) failed:", strerror(errno)); goto error_free_socket; } @@ -234,10 +236,21 @@ static int network_server_init(server *srv, buffer *host_token, specific_config srv_socket->addr.ipv6.sin6_family = AF_INET6; if (host == NULL) { srv_socket->addr.ipv6.sin6_addr = in6addr_any; + log_error_write(srv, __FILE__, __LINE__, "s", "warning: please use server.use-ipv6 only for hostnames, not without server.bind / empty address; your config will break if the kernel default for IPV6_V6ONLY changes"); } else { struct addrinfo hints, *res; int r; + if (s->set_v6only) { + val = 1; + if (-1 == setsockopt(srv_socket->fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val))) { + log_error_write(srv, __FILE__, __LINE__, "ss", "socketsockopt(IPV6_V6ONLY) failed:", strerror(errno)); + goto error_free_socket; + } + } else { + log_error_write(srv, __FILE__, __LINE__, "s", "warning: server.set-v6only will be removed soon, update your config to have different sockets for ipv4 and ipv6"); + } + memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET6; @@ -525,7 +538,7 @@ int network_init(server *srv) { if (!s->ssl_use_sslv2) { /* disable SSLv2 */ - if (SSL_OP_NO_SSLv2 != SSL_CTX_set_options(s->ssl_ctx, SSL_OP_NO_SSLv2)) { + if (!(SSL_OP_NO_SSLv2 & SSL_CTX_set_options(s->ssl_ctx, SSL_OP_NO_SSLv2))) { log_error_write(srv, __FILE__, __LINE__, "ss", "SSL:", ERR_error_string(ERR_get_error(), NULL)); return -1; @@ -711,7 +724,7 @@ int network_register_fdevents(server *srv) { server_socket *srv_socket = srv->srv_sockets.ptr[i]; fdevent_register(srv->ev, srv_socket->fd, network_server_handle_fdevent, srv_socket); - fdevent_event_add(srv->ev, &(srv_socket->fde_ndx), srv_socket->fd, FDEVENT_IN); + fdevent_event_set(srv->ev, &(srv_socket->fde_ndx), srv_socket->fd, FDEVENT_IN); } return 0; } |